Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
7 registered members (fairtrader, Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn), 581 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
2D Movement #271464
06/13/09 11:05
06/13/09 11:05
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline OP
Expert
Rei_Ayanami  Offline OP
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Hello everybody!
I trying to make a little 2D Game. The walking to the left and right is getting faster and faster when I walk! Why? And how to jump? I don´t understnad jumping, not even in 3D.

Re: 2D Movement [Re: Rei_Ayanami] #271467
06/13/09 11:10
06/13/09 11:10
Joined: Jun 2008
Posts: 402
Germany
S
sebbi91 Offline
Senior Member
sebbi91  Offline
Senior Member
S

Joined: Jun 2008
Posts: 402
Germany
please show your code because without it we cant say why it gets faster!
I think its a problem with your walkvariable , maybe a variable that gets bigger if you hit the walkkeys!


3D-Gamestudio A8 - Commercial
Re: 2D Movement [Re: sebbi91] #271469
06/13/09 11:18
06/13/09 11:18
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline OP
Expert
Rei_Ayanami  Offline OP
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Ok, I managed the problem with the too fast player myself. But how to jump???

Re: 2D Movement [Re: Rei_Ayanami] #271471
06/13/09 11:36
06/13/09 11:36
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Jump??

Is it a 2D "Sideview", "Topview" or "50° tilt" view???


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: 2D Movement [Re: Espér] #271472
06/13/09 11:41
06/13/09 11:41
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline OP
Expert
Rei_Ayanami  Offline OP
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
2D Sideview. I just work with panels.

Re: 2D Movement [Re: Rei_Ayanami] #271474
06/13/09 11:47
06/13/09 11:47
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
Try something like this:

Code:
 

var jumping = 0;

function jump()
{
  if(jumping == 0)
  {
    jumping = 1;
    x = panel.pos_x + 200;
   }    


  while(key_space)
  wait(1);
}

//// later in the code (in a loop):

...

if(jumping)
{
  if(panel.pos_y > x)  // x is the maximum jump height, panel the panel
  {   
    panel.pos_y -= 20*time_step;
    panel.pos_y = maxv(panel.pos_y,x);
  }
  else
  jumping = 0;
}
else
{
   ... // add gravity here 

  
 




No guarantuee that it works, wrote it without testing.

Re: 2D Movement [Re: the_clown] #271480
06/13/09 12:11
06/13/09 12:11
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline OP
Expert
Rei_Ayanami  Offline OP
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
OK, with some changes like a var for x. Have you got a gravity code, too wink

Re: 2D Movement [Re: Rei_Ayanami] #271482
06/13/09 12:20
06/13/09 12:20
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
Well, that would be simple, but as you're using panels only, you have to find a way to scan the "floor".
I honestly can't think of one at the moment...

Re: 2D Movement [Re: the_clown] #271486
06/13/09 12:31
06/13/09 12:31
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline OP
Expert
Rei_Ayanami  Offline OP
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Ok, you mean how I scan the distance from the player to the ground. That I have managed.
Code:
distance_to_ground = ground_pan.pos_y - player_pan.pos_y;


Re: 2D Movement [Re: Rei_Ayanami] #271496
06/13/09 13:59
06/13/09 13:59
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
Oh. Well, than, just do

if(distance_to_ground > player_pan.size_y)
player_pan.pos_y += 20*time_step;


That should work for one floor level; multiple floor levels are a bit complicated.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1