Posted: 22nd Oct 2011 21:01
i want to make a sidescrolling game, it is possible to control my char using box2d?, i am trying to control using force but my char dont move correctly, and using impulse to make him jump, anyone have tried?
Posted: 23rd Oct 2011 3:35
Are you scrolling the background or moving the charactor you really dont say which. To scroll the background is quite easy just move it over. And to make something jump you can use a sprite sheet that looks like it is jumping. I don't know what you mean by impulse.
Posted: 23rd Oct 2011 6:02
i am moving the character using box2d, like using force to push it and playing an walk animation, but its not very playable, im need some help, its a game like mario bros , if you have some sugestions , thanks.
Posted: 23rd Oct 2011 12:21
Skip box 2d and move it by changing its position instead.

Check the space shooter sample for how its done.
Posted: 23rd Oct 2011 22:10
Box2d does not give you much control. Its good for "open worlds" type of games
Posted: 24th Oct 2011 3:08
yeah, i am using kinematic mode, i have full control of my character sprite and i can move other dynamic objects , i have only one problem, i am trying to create a gravity effect on my character with setspritey command, its going very well except for detect collision with my game level, i am using GetPhysicsCollision( iSprite1, iSprite2 ) but i need to check every individual sprites, there is a way to check if my object has collided with anything in the game to stop my char moving down.
Posted: 27th Oct 2011 18:51
hi,I made this little code based on a tutorial I found on the internet about 2d character jump and run, ive tried to implement it in agk, my character jump very well except for one thing, after the first jump my char gets overlaped in the scene. here is my code, if someone show me the error will be grateful. thanks

obs: no media required, if someone can compile to see,
+ Code Snippet
// Landscape App
setvirtualresolution(1024,768)
SetSyncRate(30,1)

//create my char
jogador = createsprite(0)
setspritecolor(jogador,255,0,255,255)
setspritesize(jogador,50,100)
setspritepositionbyoffset(jogador,1024/2,768/2)

//... and the scene
cenario = createsprite(0)
setspritecolor(cenario,0,0,255,255)
setspritesize(cenario,500,50)
setspritepositionbyoffset(cenario,1024/2,768/1.5)

//initialize var
gravity# = 9.8
moving = 0
jumping = 0

//debugmode
setphysicsdebugon()


do

        tecla = getrawlastkey()
        jumpkeypressed = getrawkeystate(32)
        jogadorx# = getspritex(jogador)
        jogadory# = getspritey(jogador)
        //groundy# = getspritey(cenario)

 //intialize y velocity
 //jumping boolean when jump key is pressed
        if jumping = 0 and jumpKeyPressed = 1

            velocity_y# = 80.0
            //gravity# = 9.8
            jumping = 1

        endif

        if jumping = 1

                  jogadory# = jogadory# - velocity_y#
                  velocity_y# = velocity_y# - gravity#
                  setspritey(jogador,jogadory#)

        endif

//init moving boolean when walk key is pressed
//init velocity_x
 //       if moving = 0 and leftKeyPressed = 1

 //           moving = 1
 //           velocity_x# = -10

 //       elseif  moving = 0 and rightKeyPressed = 1

  //          moving = 1
 //           velocity_x# = 10

 //       else
 //               moving = 0

 //       endif

        //move object by x velocity
        //if moving = 1 then jogadorx# = jogadorx# + velocity_x#

        setspritey(jogador,jogadory#+gravity#)

        if getspritecollision(jogador,cenario)=1
                setspritey(jogador,jogadory#)
                velocity_y# = 0
                jumping = 0
        endif

//setspritey(jogador,jogadory#+gravity#)

        print("Timer: "+str(timer(),0))
        print("FPS: "+str(screenfps(),0))
        print("Tecla: "+str(tecla))
        print("JumpkeyPressed?: "+str(JumpkeyPressed))
        print("Jogador Y: "+str(jogadory#))
        print("Cenario Y: "+str(groundy#))
        sync()
loop
//end game loop