first problem in Your first game tutorial

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Lady

I’m following the Docs and stuck in the first part of Your First Game.
The instructions say to put this:

position += velocity * delta
position.x = clamp(position.x, 0, screen_size.x)
position.y = clamp(position.y, 0, screen_size.y)

under the _process function

I put it under the previous lines of code - not know for sure where it is supposed to go. I get an error of an unexpected token: identifier:position

Where should the position code go?

I have coded in Flash for many decades - pretty good at AS2 so this is a little different. It would be helpful in the docs to show what the code should look like before testing the game. I test the game and only get the Godot splash screen.

:bust_in_silhouette: Reply From: kidscancode

It seems likely you didn’t indent those three lines. You’re correct they go after the previous lines, but they still belong in the _process() function, so they must be indented.

I figured out what was causing the problem. I had copied and pasted the code from the Docs which removed the Tab for the indent and put in spaces instead. When I deleted the spaces replacing them with Tabs it was happier.

Lady | 2019-06-30 18:41

Yes, that’s a common problem when copying from web pages.

Just a tip: when doing tutorials, always type the code yourself. You will learn, and retain, much more than if you copy-and-paste.

kidscancode | 2019-06-30 18:59