ive tried { } and ; its still not working :( im frustrated

Twisty

Member
I feel like everything i want to happen for my simple game is not working for me. i cant grasp whats going on and why ive been using tutorials and i cant even get them right. is this what happens for everyone who's a beginner. the frustration?

___________________________________________
FATAL ERROR in
action number 1
of Step Event
for object obj_enemy:

COMPILATION ERROR in code action
Error in code at line 51:

^
at position 1: Assignment operator expected.




GML:
// enenmy
if (place_meeting(x,y,obj_player))
{
     if (obj_player.y < y -16)
     {
     with (obj_player) vsp = -jumpspeed;
     instance_destroy();
    
     }
else
{
game_restart();
{
}
}
sample
/*if (!place_free(x + hspeed, y)) if (state== "left" ) state = "right"; else state = "left" ;

if (place_free(x + hspeed, y) and place_free(x + hspeed * 16, y + 16)) if (state== "left" ) state = "right" else state = "left;
}
*/
 

chamaeleon

Member
I feel like everything i want to happen for my simple game is not working for me. i cant grasp whats going on and why ive been using tutorials and i cant even get them right. is this what happens for everyone who's a beginner. the frustration?

___________________________________________
FATAL ERROR in
action number 1
of Step Event
for object obj_enemy:

COMPILATION ERROR in code action
Error in code at line 51:

^
at position 1: Assignment operator expected.




GML:
// enenmy
if (place_meeting(x,y,obj_player))
{
     if (obj_player.y < y -16)
     {
     with (obj_player) vsp = -jumpspeed;
     instance_destroy();
   
     }
else
{
game_restart();
{
}
}
sample
/*if (!place_free(x + hspeed, y)) if (state== "left" ) state = "right"; else state = "left" ;

if (place_free(x + hspeed, y) and place_free(x + hspeed * 16, y + 16)) if (state== "left" ) state = "right" else state = "left;
}
*/
GML:
// enenmy
if (place_meeting(x,y,obj_player))
{
    if (obj_player.y < y -16)
    {
        with (obj_player) vsp = -jumpspeed;
        instance_destroy();
    }
    else
    {
        game_restart();
    }
}
 

Fanatrick

Member
You must close every bracket you open, from just glancing it's clear to see there's one missing:

scr.png

Of course you're frustrated, you're trying to skip important steps in grasping what you're trying to do. Instead of people fixing things for you without explaining I would instead advise you to take it easy and learn at your own pace. Refer to the manual.
 
You have four open brackets and only three closed brackets. And yes, frustration does set in when you're trying to code, whether you're a beginner or not. Just have a little patience, take a breath, and learn to go through your code for simple but easy to overlook things like missing semicolons and proper number of brackets. What I find helps with that last one is writing out the brackets first, then going back to write the code inside them. When you start having brackets nested inside brackets nested inside brackets, it really helps.
 

Sybok

Member
Pretty confident that the error being thrown is dues to 'sample', as I stated. But agreed he will get parenthesis issues when he fixes that, due to him having the rest of the code commented out (the closing bracket is there, it's just commented out).

I was helping him fix it one step at a time rather than give him a wholistic cut and past "here's your answer" solution. That doesn't help him in the long run.

Its better for him to understand the traps that he keeps repeating.
 
Indent your code correctly! You're in for a world of pain if you don't! :p
I prefer Allman style, but there are a bunch of others:

Code:
if(indentingCode)
{
      codingEasy = true;
      if(moreThanOneSetOfCurlyBraces)
      {
            indentAgain = true;
            if(RHC)
            {
                  coolDude = true;
            }
      }
}
else
{
      codingEasy = false;
      //Have fun suffering, lol
}
Pick one you like and stick with it! Coding comes with a million headaches that you won't be able to avoid. Avoid the ones you can at least, hahah! ;P
 
Last edited:
I'm guessing OP wanted the word sample commented out, too, as the commented-out code is probably "sample" code from a tutorial they're following. But yeah, that'll throw an error, too.

And I'd like to wholeheartedly agree on the indentation thing. Consistent indentation will make your code a whole lot easier to read in the long run.
 

Sybok

Member
As for myself, I was visually trying to show the importance of a consistent indentation. Maybe I should have left the braces alone, but I did not in this case.
That's why I thought the down vote from Fanatrick was a little unwarranted. Maybe he figured his spelling it out was the better solution in his mind, rather than to have him work a little to see the mistakes that we were subtly pointing out.

Indenting the code @RichHopefulComposer said is really a must. An unnessesary world of pain and suffering if you don't.
 

Sybok

Member
I'm guessing OP wanted the word sample commented out, too, as the commented-out code is probably "sample" code from a tutorial they're following. But yeah, that'll throw an error, too.
Guarantee that "sample" is throwing this particular error. I was going to let him get back to us with the next error. But you spoiled the learning curve :p
 

Twisty

Member
You must close every bracket you open, from just glancing it's clear to see there's one missing:

View attachment 30927

Of course you're frustrated, you're trying to skip important steps in grasping what you're trying to do. Instead of people fixing things for you without explaining I would instead advise you to take it easy and learn at your own pace. Refer to the manual.
if i cant understand the manual how do i recieve help because i refered to the manual and i couldnt understand it
 

Twisty

Member
What does 'sample' do? ;)
Sybok i find you helpful and supportive what my code sameple was meant to be was another way for my enemy to not walk off platform anyway im just very confused and i know u guys want to help me without giving me the answers and im not trying to be all about getting answers from u but i dont know how to understand some things and i seek lots of support. how can i get support without just asking for answers?
 
Last edited:
if i cant understand the manual how do i recieve help because i refered to the manual and i couldnt understand it
If you can read, you'll be able to understand the manual with enough effort, I'm sure. You're posting here, so I'm sure you'll get it if you take it one step at a time.
Don't feel bad if it takes awhile, though. Programming is a big task to learn, and there's no way to really learn everything in perfect order; you'll learn things, forget them, and then learn them again and understand them better the second time around. You just have to keep suffering and studying for months and months. Slowly, things will click. I'd suggest going through all the beginner tutorials that come with GM after skimming through the manual and retaining as much as you can.

It's boring and a huge headache learning all the basics, but without the basics, you're setting yourself up for even more headaches.


Welcome to game development! Get ready for a lot of miserable days and nights, hahah! ;)
 

Sybok

Member
Sybok i find you helpful and supportive what my code was meant to do was make sure my enemy doesnt walk of a platform higher than 8px anyway im just very confused and i know u guys want to help me without giving me the answers and im not trying to be all about getting answers from u but i dont know how to understand some things and i seek lots of support. how can i get support without just asking for answers?
It's great that you are trying to learn this. :)

I'd even take a step back a bit and make even simpler projects. I have to keep reminding my own son of this too. He learned how to draw text to the screen in Python a few days ago and now he is trying to make Crysis 4. 🤣

Pick something simple. Start a new project, put a sprite on the screen, move it around with keyboard movement.

Once you have done that, see if you can play a sound when it touches something.

Continually build from there. You'll get plenty of problems on the way, see if you can solve them, if not, post here we will help. :)

Following videos on the internet is ok to an extent, but you really need to built up a foundation to add your knowledge to.

Don't start out trying to make Crysis as your first game :D

We've all been there. My first attempt ever was an MMO - LOL. I don't need to tell you how that turned out. 😁
 

Twisty

Member
GML:
// enenmy
if (place_meeting(x,y,obj_player))
{
    if (obj_player.y < y -16)
    {
        with (obj_player) vsp = -jumpspeed;
        instance_destroy();
    }
    else
    {
        game_restart();
    }
}
If you can read, you'll be able to understand the manual with enough effort, I'm sure. You're posting here, so I'm sure you'll get it if you take it one step at a time.
Don't feel bad if it takes awhile, though. Programming is a big task to learn, and there's no way to really learn everything in perfect order; you'll learn things, forget them, and then learn them again and understand them better the second time around. You just have to keep suffering and studying for months and months. Slowly, things will click. I'd suggest going through all the beginner tutorials that come with GM after skimming through the manual and retaining as much as you can.

It's boring and a huge headache learning all the basics, but without the basics, you're setting yourself up for even more headaches.


Welcome to game development! Get ready for a lot of miserable days and nights, hahah! ;)
I'm guessing OP wanted the word sample commented out, too, as the commented-out code is probably "sample" code from a tutorial they're following. But yeah, that'll throw an error, too.

And I'd like to wholeheartedly agree on the indentation thing. Consistent indentation will make your code a whole lot easier to read in the long run.
That's why I thought the down vote from Fanatrick was a little unwarranted. Maybe he figured his spelling it out was the better solution in his mind, rather than to have him work a little to see the mistakes that we were subtly pointing out.

Indenting the code @RichHopefulComposer said is really a must. An unnessesary world of pain and suffering if you don't.
Aye when i get coding and make some good projects ill have all you guys to thank for putting me through the pain and suffering hahaha :)
 

Twisty

Member
It's great that you are trying to learn this. :)

I'd even take a step back a bit and make even simpler projects. I have to keep reminding my own son of this too. He learned how to draw text to the screen in Python a few days ago and now he is trying to make Crysis 4. 🤣

Pick something simple. Start a new project, put a sprite on the screen, move it around with keyboard movement.

Once you have done that, see if you can play a sound when it touches something.

Continually build from there. You'll get plenty of problems on the way, see if you can solve them, if not, post here we will help. :)

Following videos on the internet is ok to an extent, but you really need to built up a foundation to add your knowledge to.

Don't start out trying to make Crysis as your first game :D

We've all been there. My first attempt ever was an MMO - LOL. I don't need to tell you how that turned out. 😁
hahahahah thankyou that actually is pretty helpful advice. i guess i thought i could handle it but i guess i cant at this present time.
 
I was going to let him get back to us with the next error. But you spoiled the learning curve :p
Yeah, sorry. I took away the joy of fixing an error only to be hit with a second, entirely unrelated error. Oops. :rolleyes:

if i cant understand the manual how do i recieve help because i refered to the manual and i couldnt understand it
You do exactly what you're doing. Go through beginner tutorials, ask questions here. Most of the people on the GMC can tell (and appreciate) the difference between someone that's at their wits end and someone that's looking to be handed code. And I'd agree that, especially for beginners, the manual can sometimes not do a great job of explaining when you would use given functions. But once you start to get a grasp on things, it can be invaluable for reminding yourself how to structure your code. Start with basics: variables, if statements. You'll know when you're confident enough to move on from there.

when i get coding and make some good projects ill have all you guys to thank for putting me through the pain and suffering
You think that once you're able to make good projects you're through with the pain and suffering? Oh my God, that's cute. ;)
 

Sybok

Member
hahahahah thankyou that actually is pretty helpful advice. i guess i thought i could handle it but i guess i cant at this present time.
And that's not a bad thing. It's really great to recognise when you are in too deep. That's where you break it down in to bite (byte? 🤣 ) sized chunks and attack things that way. Every time you do this, you will most certainly come away every day, knowing that you are starting to get this.

Then you will develop your own coding style and even then people will often tell you 'you are doing it wrong'. But there are no rules, if you make it work, it works! The end user doesn't care what the underlying code looks like. As long as you understand what is going on, that's all that matters.


You think that once you're able to make good projects you're through with the pain and suffering? Oh my God, that's cute. ;)
Haha! It never ends!
 

Twisty

Member
You think that once you're able to make good projects you're through with the pain and suffering? Oh my God, that's cute. ;)
no i never was meaning it like that i was just meaning it like id get coding much better and id have a better understanding HAHA
 

Sybok

Member
Would maybe a maze game be a good starting point?
In all honesty, I'd take it right back at this stage. Doing what I mentioned earlier would probably be my line of thinking. Maybe something like this (in this rough order).

- Get a character on the screen
- Get him to move around
- Constrain him to the boundaries of the screen
- Put some coins on the screen
- Get character to collect the coins (make the coins disappear)
- Play a sound each time a coin is collected
- Create a winning screen when all coins are collected

Sounds dull and pretty boring. But you'll run in to your fair share of problems just by doing that. Which is fine and expected :)
 

Felbar

Member
You are trying to run before you can walk, this is going to lead to endless frustration.
You need to learn the fundamentals of programming before you can hope to code something as complex as a game.
It takes time I understand , you want to do the neat stuff.
Endlessly trying to tackle problems that are above your abilities is going to make you quit, not make you better.
There are many many GML and other basic coding tutorials on the net , do some googling.
Start small ,variables and assignments then operators, then conditionals , loops etc.
There is no quick way to become a good programmer it literally takes years, I am not trying to discourage you,
you need to understand the commitment it takes.
 
Top