Log In  


Im creates jump function in my game, but im dont know how to stop program.

This is the _jump() function code:

function _jump()
y-=5
y+=5

In comment, please tell me how to do this.
Im dont want to use "flip()".
This command doesnt stops program, only frames.



You need to look at "game states" and some conditions to switch between states.

The code below demonstrates the key concepts:

  • game state
  • condition to return to "idle" state
-- is player "flying"
on_air=false
-- height
y=0
-- jump force
dy=0

function _update()
 -- not yet jumping?
 if on_air==falseand btn(4) then
   -- jumping
   on_air=true
   -- jump "force"
   dy=8
 end

 -- gravity
 y+=-1.2
 -- jump force (if any)
 y+=dy
 -- gravity drag
 dy*=0.8
 -- on ground?
 if y<0 then
  	y=0
        -- reset state
  	dy=0
  	on_air=false
  end
end

function _draw()
 cls()
 -- jumping "hi"!
 print("hi",64,122-y,7)
 -- ground
 line(0,127,127,127,3)
end

Look at the Jelpi sample for a more complete example.


VERY THX!!!



[Please log in to post a comment]