Annoying variable type error

BlitzPlus Forums/BlitzPlus Programming/Annoying variable type error

D2(Posted 2007) [#1]
I'm making a scrolling shooter, and this annoying error message pops up when I try to run it, saying "variable must be a type." I dunno why it's doing this: I clearly set up the player type, and I believe I'm following all the proper syntax. Why, then, is this happening?

PS: Sorry, I don't know how to designate my typing as a code section, so the code starts here:

;/////// INIT ///////


;set up the graphics
Graphics 600,800

;enable double buffering
SetBuffer BackBuffer

;enable AutoMidHandle
AutoMidHandle True

;set key constants
Const KEY_ESC=1 ;escape

Const KEY_LEFT=203 ;left
Const KEY_RIGHT=205 ;right
Const KEY_UP=200 ;up
Const KEY_DOWN=208 ;down

;load the ship image
playerImage = LoadImage("ship_idle.bmp")

;player type
Type player
Field x,y
End Type

;create player
player1.player = New player
player\x = 400
player\y = 300


;/////// MAIN LOOP ///////

While Not KeyHit(KEY_ESC)

;clear screen
Cls

;move left
If KeyDown(KEY_LEFT)
player\x = player\x - 5
EndIf

;move right
If KeyDown(KEY_RIGHT)
player\x = player\x + 5
EndIf

;move up
If KeyDown(KEY_UP)
player\y = player\y - 5
EndIf


H&K(Posted 2007) [#2]
[code]
[/code]
or
[/codebox]
Does the error not tell you which line?


D2(Posted 2007) [#3]
Yes, it does, assuming the cursor jumping to a specific line means so. It is:



It's really confusing


H&K(Posted 2007) [#4]
player1\x =400
This is a common mistake to make, mistaking the type for the instance.
And to avoid it, you will find that many many people will aways call there type TPlayer or TAlien etc.
I go so far as all instances are called APlayer, AAlien or MyPlayer1, etc

MyPlayer1.TPlayer = new TPlayer


D2(Posted 2007) [#5]
No, actually the complete three lines at fault are this:
player.player = New player
player\x = 400
player\y = 300


Looks just fine to me

EDIT: I think I got it now:
player1.player = New player 
player1\x = 400
player1\y = 300


working fine.

Also, I reversed the resolution values (so it's wider than it is tall) and put () next to BackBuffer (otherwise it was giving me "invalid buffer handle") Thanks for your help :P