Supertino the character uses gravity but trying to move against the gravity has that effect as I opted for a touch screen style movement
I still may have to go with virtual joysticks yet or atleast configure my routine a bit I might try a timer on the touchscreen basis yet so you
just click in front of the character and the character responds. but still playing with that idea yet, as I posted my code above hoping someone
might have solved the problem better than I, and know of some tweeks I could use. The gravity is currently set to 150, the touch style movement
worked well for my frogger and other games ive made, just I'm trying to work out how I can do that with a platform game, This will also be my first
platform game with any of The Game Creators tools aswell
Thanks for the feedback positive criticism is always welcome
using a Timer based clicking event seems to work much better but as expected you have to keep clicking which is the way I was testing it on an android
tablet but for the videos I used a pc and the flighty controls were useful in testing collisions the code for the movement now looks like.
if GetPointerState() = 1
if Timer()-moveTime#<2
ft# = getFrameTime()*2
x#=GetPointerX():y# = GetPointerY()
cx#=GetSpriteXByOffset(StickFigureSpr):cy# = getSpriteYbyOffset(StickFigureSpr)
newx# = cx#-(cx#-x#)*ft#:newy# = cy#-(cy#-y#)*ft#
//if theres a significant difference between pointer and sprite then jump
yDifference=abs(Difference(y#,newy#)):xDifference=abs(Difference(x#,newx#))
if yDifference >40 and yDifference>xDifference
if direction=-1 then PlaySprite(StickFigureSpr,10,0,33,38) //jump left animation
if direction=1 then PlaySprite(StickFigureSpr,10,0,41,46) //jump right animation
else
newy#=cy# //dont jump at all
endif
//check which direction sprite should be facing and animation
if newx#>x# then direction=-1
if newx#<x# then direction=1
if GetSpritePlaying(StickFigureSpr)=0 //and yDifference <40
if newx#>x# then PlaySprite(StickFigureSpr,14,0,9,16) //walk left animation
if newx#<x# then PlaySprite(StickFigureSpr,14,0,1,8) //walk right animation
endif
//SetSpritePositionByOffset(StickFigureSpr,newx#,newy#)
if direction=1 and GetSpriteHitGroup(0,GetSpriteXByOffset(StickFigureSpr)+33,GetSpriteYByOffset(StickFigureSpr))=0
if GetSpriteXByOffset(1)>-(xMax-96) //move man right
move_background(Difference(cx#,newx#))
SetSpritePositionByOffset(StickFigureSpr,GetSpriteXByOffset(StickFigureSpr),newy#)
else
SetSpritePositionByOffset(StickFigureSpr,newx#,newy#)
endif
endif
if direction=-1 and GetSpriteHitGroup(0,GetSpriteXByOffset(StickFigureSpr)-33,GetSpriteYByOffset(StickFigureSpr))=0
if GetSpriteXByOffset(1)<32.0 //move man left
move_background(Difference(cx#,newx#))
SetSpritePositionByOffset(StickFigureSpr,GetSpriteXByOffset(StickFigureSpr),newy#)
else
SetSpritePositionByOffset(StickFigureSpr,newx#,newy#)
endif
endif
if GetSpriteX(StickFigureSpr)<32.0 then SetSpriteX(StickFigureSpr,32)
if GetSpriteX(StickFigureSpr)>xMaxView-128 then SetSpriteX(StickFigureSpr,xMaxView-128)
endif
else
if GetSpritePlaying(StickFigureSpr)=0 //and oldy#=getSpriteYbyOffset(StickFigureSpr)
if direction=-1 then PlaySprite(StickFigureSpr,14,0,40,40) //stop and face sprite left
if direction=1 then PlaySprite(StickFigureSpr,14,0,39,39) //stop and face sprite right
endif
moveTime#=Timer()
endif if GetPointerState() = 1
if Timer()-moveTime#<2
ft# = getFrameTime()*2
x#=GetPointerX():y# = GetPointerY()
cx#=GetSpriteXByOffset(StickFigureSpr):cy# = getSpriteYbyOffset(StickFigureSpr)
newx# = cx#-(cx#-x#)*ft#:newy# = cy#-(cy#-y#)*ft#
//if theres a significant difference between pointer and sprite then jump
yDifference=abs(Difference(y#,newy#)):xDifference=abs(Difference(x#,newx#))
if yDifference >40 and yDifference>xDifference
if direction=-1 then PlaySprite(StickFigureSpr,10,0,33,38) //jump left animation
if direction=1 then PlaySprite(StickFigureSpr,10,0,41,46) //jump right animation
else
newy#=cy# //dont jump at all
endif
//check which direction sprite should be facing and animation
if newx#>x# then direction=-1
if newx#<x# then direction=1
if GetSpritePlaying(StickFigureSpr)=0 //and yDifference <40
if newx#>x# then PlaySprite(StickFigureSpr,14,0,9,16) //walk left animation
if newx#<x# then PlaySprite(StickFigureSpr,14,0,1,8) //walk right animation
endif
//SetSpritePositionByOffset(StickFigureSpr,newx#,newy#)
if direction=1 and GetSpriteHitGroup(0,GetSpriteXByOffset(StickFigureSpr)+33,GetSpriteYByOffset(StickFigureSpr))=0
if GetSpriteXByOffset(1)>-(xMax-96) //move man right
move_background(Difference(cx#,newx#))
SetSpritePositionByOffset(StickFigureSpr,GetSpriteXByOffset(StickFigureSpr),newy#)
else
SetSpritePositionByOffset(StickFigureSpr,newx#,newy#)
endif
endif
if direction=-1 and GetSpriteHitGroup(0,GetSpriteXByOffset(StickFigureSpr)-33,GetSpriteYByOffset(StickFigureSpr))=0
if GetSpriteXByOffset(1)<32.0 //move man left
move_background(Difference(cx#,newx#))
SetSpritePositionByOffset(StickFigureSpr,GetSpriteXByOffset(StickFigureSpr),newy#)
else
SetSpritePositionByOffset(StickFigureSpr,newx#,newy#)
endif
endif
if GetSpriteX(StickFigureSpr)<32.0 then SetSpriteX(StickFigureSpr,32)
if GetSpriteX(StickFigureSpr)>xMaxView-128 then SetSpriteX(StickFigureSpr,xMaxView-128)
endif
else
if GetSpritePlaying(StickFigureSpr)=0 //and oldy#=getSpriteYbyOffset(StickFigureSpr)
if direction=-1 then PlaySprite(StickFigureSpr,14,0,40,40) //stop and face sprite left
if direction=1 then PlaySprite(StickFigureSpr,14,0,39,39) //stop and face sprite right
endif
moveTime#=Timer()
endif
and without the timer event and changing
newy#=cy# //dont jump at al
to newy#=cy#+3
helps allot too
fubar