Original Post
I have a little problem here.. Whenever I compile my code, it will for a few seconds (after moving the character around a bit) and then it gives me an error about illegal memory address. I've searched my code and I could find whats wrong. In my walking bitmaps I have 7 images of the guy walking (just incase you need that info) Here's my code: Graphics 800,600,16,3 AutoMidHandle True SetBuffer BackBuffer() ;GLOBALS/TYPES Global fps = CreateTimer(12) Global frames = 0 Type Hero Field x,y,frame,action;action: 1-Stand,2-Walk,3-Run Field img,dir;dir: 1-Right,2-Left Field imgwl,imgwr Field imgsl,imgsr End Type ;INITS Global Baleog.Hero = New Hero Baleog\x = 400 Baleog\y = 300 Baleog\frame = 0 Baleog\action = 1 Baleog\dir = 1 Baleog\imgwl = LoadAnimImage("Baleog\BaleogWalkLeft.bmp",33,32,0,7) Baleog\imgwr = LoadAnimImage("Baleog\BaleogWalkRight.bmp",33,32,0,7) Baleog\imgsl = LoadImage("Baleog\BaleogStandLeft.bmp") Baleog\imgsr = LoadImage("Baleog\BaleogStandRight.bmp") Baleog\img = Baleog\imgsr MaskImage Baleog\imgwl,255,0,255 MaskImage Baleog\imgwr,255,0,255 MaskImage Baleog\imgsl,255,0,255 MaskImage Baleog\imgsr,255,0,255 ;MAIN LOOP While(Not KeyDown(1)) frames = WaitTimer(fps) For i=0 To frames UpdateGame() Next Cls RenderHero() Flip Wend End ;FUNCTIONS Function UpdateGame() If(KeyDown(205)) Baleog\x = Baleog\x+5 Baleog\frame = Baleog\frame+1 Baleog\dir = 1 Baleog\action = 2 ElseIf(KeyDown(203)) Baleog\x = Baleog\x-5 Baleog\frame = Baleog\frame-1 Baleog\dir = 0 Baleog\action = 2 Else Baleog\action = 1 EndIf If(Baleog\frame < 0) Baleog\frame = 6 ElseIf(Baleog\frame > 6) Baleog\frame = 0 EndIf End Function Function RenderHero() Select Baleog\action Case 1;Stand If Baleog\dir=1;Right Baleog\img = Baleog\imgsr Else;Left Baleog\img = Baleog\imgsl EndIf Case 2;Walk If Baleog\dir=1 Baleog\img = Baleog\imgwr Else Baleog\img = Baleog\imgwl EndIf End Select DrawImage Baleog\img,Baleog\x,Baleog\y,Baleog\frame End Function