Not sure

BlitzPlus Forums/BlitzPlus Beginners Area/Not sure

Grunthunter(Posted 2005) [#1]
Hey friends,
Im a new to this code and am not sure if I am doing this right. I'm also not sure if I am drawing a new picture each and every time I move. Does this look right?

Thanks

ps. does anyone know if the "Learn how to program with Blitz 2D" is any good?


Graphics 640,480
SetBuffer BackBuffer()
Global player=LoadImage("graphics\alien.bmp")
Global speed=3
Global p.player=New player

Type player
Field x,y
End Type

While Not KeyHit(1)

updateplayer()
drawplayer()
Wend
FreeImage player
End

Function updateplayer()

If KeyDown(203) Then p\x=p\x - speed
If KeyDown(205) Then p\x=p\x + speed
If KeyDown(200) Then p\y=p\y - speed
If KeyDown(208) Then p\y=p\y + speed

If p\x<-25 Then p\x=650
If p\y<-25 Then p\y=490
If p\x>650 Then p\x=-25
If p\y>490 Then p\y=-25
End Function

Function drawplayer()
Cls
DrawImage player,p\x,p\y
Flip
End Function


Nicstt(Posted 2005) [#2]
Looks fine to me

I never declare types as globals, appears to be no need. Although if u didnt u would be calling them.

I tend to use globals when I have to, otherwise local variables, can help with debugging on larger projects imo.

No idea on the book, I ask questions here when I have any.


WolRon(Posted 2005) [#3]
You can always check out my Programming Tutorial. It's not finished but it will be someday...


Grunthunter(Posted 2005) [#4]
thanks guys


Rck(Posted 2005) [#5]
What are the forum codes?