first of all sorry it took so long, right after my last post i ended up playing some gta for a very long time.
ok i think i have what your looking for now, it was relatively easy. i just took a few min to study your code and see what you were trying to do and how you were trying to do it. after a few more min i came up with what i think/hope you were asking for. i only changed a small percentage of your code slightly but you'll notice whats different, i stayed as close to your style as i could. i remarked what i added as '*******New*****.
anyway here's the new code
i hope that helps ya out.
as a side note:
i'm gonna have to agree with tony. doing small simple programs like that is one thing. but when you get into making larger programs, it'll be hell to read and follow. you need to structure your code. start by just using functions and then later on get into using types with methods and functions, you'll do your self a huge favour.
i know from expierence, when i first started coding thats exactly how i did it. its a very bad habbit and the longer one codes with out structure the harder it is to break that habbit.
ok i think i have what your looking for now, it was relatively easy. i just took a few min to study your code and see what you were trying to do and how you were trying to do it. after a few more min i came up with what i think/hope you were asking for. i only changed a small percentage of your code slightly but you'll notice whats different, i stayed as close to your style as i could. i remarked what i added as '*******New*****.
anyway here's the new code
' collison / animation testing AutoImageFlags 0 Const width =640 Const hieght = 480 Const colour_depth = 0 AppTitle = "animtest" Graphics width,hieght,colour_depth Global hWnd% = GetActiveWindow() ' Save current Window handle 'timer Global tmr:Int = MilliSecs() Global frame:Int=0 Global anim_speed:Int=100 boarder = LoadImage ("level/boarder.bmp") 'background = LoadImage ("level/final back ground5.bmp") walkable_area =LoadImage ("level/final back walkable2.png") block=LoadImage ("level/colideblock.bmp") pointer = LoadImage ("level/pointer.png") indy_r = LoadImage ("level/sprites/indy_r.png") indy_wr = LoadAnimImage("level/sprites/indy_wr.png",32,64,0,6) indy_wl = LoadAnimImage("level/sprites/indy_wl.png",32,64,0,6) '******New***** indy_wu = LoadAnimImage("level/sprites/indy_wu.png",32,64,0,4) indy_wd = LoadAnimImage("level/sprites/indy_wd.png",32,64,0,4) '************** SetImageHandle indy_r,16,60 SetImageHandle indy_wr,16,60 SetImageHandle indy_wl,16,60 SetImageHandle block,8,4 Global block_xpos:Int = 300 Global block_ypos:Int = 230 Global old_x:Int = block_xpos Global old_y:Int = block_ypos Global xtarget:Int = 300 Global ytarget:Int = 230 Global scale:Float = 1.1 Global offset:Int = 0 HideMouse() While Not KeyHit(key_escape) If MouseHit(1) frame = 0 '*****New***** xtarget = MouseX() ytarget = MouseY() EndIf DrawImage(boarder,0,0) SetViewport(40,40,560,420)'set to limit level to inside boarder 560x220. DrawImage(walkable_area,40 + offset,40) DrawImage(block,block_xpos + offset,block_ypos) 'DrawImage(background,40 + offset,40) SetViewport(0,0,640,480) 'set back for mouse over If old_x = block_xpos And old_y = block_ypos DrawImage(indy_r,block_xpos,block_ypos) Else If old_x > block_xpos If MilliSecs() >tmr + anim_speed tmr = MilliSecs() frame = frame +1 EndIf If frame = 6 Then frame =0 DrawImage(indy_wl,block_xpos,block_ypos,frame) EndIf '******New***** If old_x < block_xpos If MilliSecs() >tmr + anim_speed tmr = MilliSecs() frame = frame +1 EndIf If frame = 6 Then frame =0 DrawImage(indy_wr,block_xpos,block_ypos,frame) EndIf If old_x = block_xpos And old_y < block_ypos If MilliSecs() >tmr + anim_speed tmr = MilliSecs() frame = frame +1 EndIf If frame > 3 Then frame =0 'i had to add on x and y offset for the up/down images ' because your not using midhandleand i didn't want to modify your code too much. DrawImage(indy_wd,block_xpos-15,block_ypos-60,frame) EndIf If old_x = block_xpos And old_y > block_ypos If MilliSecs() >tmr + anim_speed tmr = MilliSecs() frame = frame +1 EndIf If frame > 3 Then frame =0 DrawImage(indy_wu,block_xpos-15,block_ypos-60,frame) EndIf '************** EndIf ResetCollisions() old_y = block_ypos old_x = block_xpos 'move up If block_ypos > ytarget If ImagesCollide(block,block_xpos,block_ypos-1,0,walkable_area,40,40,0)= 0 block_ypos:- 1 EndIf EndIf ResetCollisions() 'move down If block_ypos < ytarget If ImagesCollide(block,block_xpos,block_ypos+1,0,walkable_area,40,40,0)= 0 block_ypos:+ 1 EndIf EndIf ResetCollisions() 'move left If block_xpos > xtarget If ImagesCollide(block,block_xpos-1,block_ypos,0,walkable_area,40,40,0)= 0 block_xpos:- 1 EndIf EndIf ResetCollisions() 'move right If block_xpos < xtarget If ImagesCollide(block,block_xpos+1,block_ypos,0,walkable_area,40,40,0)= 0 block_xpos:+ 1 EndIf EndIf ResetCollisions() ResetCollisions() Local m_x:Int = MouseX() Local m_y:Int = MouseY() DrawImage(pointer,m_x:Int,m_y:Int) ' close window button now works ########### If AppTerminate() Then ' insert garbage clear up here <<<<< End EndIf '########################################## Flip Cls Wend
i hope that helps ya out.
as a side note:
i'm gonna have to agree with tony. doing small simple programs like that is one thing. but when you get into making larger programs, it'll be hell to read and follow. you need to structure your code. start by just using functions and then later on get into using types with methods and functions, you'll do your self a huge favour.
i know from expierence, when i first started coding thats exactly how i did it. its a very bad habbit and the longer one codes with out structure the harder it is to break that habbit.