Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
6 registered members (AndrewAMD, Ayumi, degenerate_762, 7th_zorro, VoroneTZ, HoopyDerFrood), 1,268 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
problem with jump function #248151
01/24/09 22:05
01/24/09 22:05
Joined: Jun 2007
Posts: 152
Norway
D
Darkyyes Offline OP
Member
Darkyyes  Offline OP
Member
D

Joined: Jun 2007
Posts: 152
Norway
tried to make a jump function like the one in AUM
but the thing is I dont want the move keys to be inserted in the

if (!jump_height) call

Is there another way to do it? if so could you show me?


New to lite-c and gamestudio in general, thank you for reading.
Com, A7 v7.7
Re: problem with jump function [Re: Darkyyes] #248368
01/26/09 12:58
01/26/09 12:58
Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
What is the number of the magazine? What is the name of the article?

Re: problem with jump function [Re: George] #248389
01/26/09 16:02
01/26/09 16:02
Joined: Jun 2007
Posts: 152
Norway
D
Darkyyes Offline OP
Member
Darkyyes  Offline OP
Member
D

Joined: Jun 2007
Posts: 152
Norway
aum79
unanswered questions

Code:
action player_code()

{ 

       VECTOR temp[3];

       VECTOR movement_speed[3]; // player's movement speed

       var anim_percentage; // animation percentage

       var jump_percentage; // animation percentage for jumping

       var distance_to_ground; // the distance between player's origin and the ground

       var jump_height;

       var reached_height;

       player = my; // I'm the player

       while (1)

       {

               my.pan += 6 * (key_a - key_d) * time_step; // rotate the player using the "A" and "D" keys

               vec_set (temp.x, my.x); // copy player's position to temp

               temp.z -= 10000; // set temp.z 10000 quants below player's origin

               distance_to_ground = c_trace (my.x, temp.x, IGNORE_ME | USE_BOX);

               movement_speed.x = 5 * (key_w - key_s) * time_step; // move the player using "W" and "S"

               movement_speed.y = 0; // don't move sideways

               if (key_space && !reached_height)

               {

                       jump_height = minv(40, jump_height + 5 * time_step); // 40 sets the height, 5 sets the ascending speed

                       if (jump_height == 40) // reached the maximum height? Then start descending!

                       {

                               reached_height = 1;

                               jump_height = maxv(0, jump_height - 5 * time_step); // 5 sets the falling speed

                       }

               }

               else // space isn't pressed anymore?

               {

                       jump_height = maxv(0, jump_height - 3 * time_step); // use a smaller falling speed (3) for smaller jumps

                       if (!jump_height && !key_space) // the player has touched the ground?

                       {

                               reached_height = 0; // then allow it to jump again

                       }

               }

               movement_speed.z = -(distance_to_ground - 17) + jump_height; // 17 = experimental value

            movement_speed.z = maxv(-35 * time_step, movement_speed.z); // 35 = falling speed

               c_move (my, movement_speed.x, nullvector, GLIDE); // move the player

            if (!jump_height) // the player isn't jumping?

            {

                    if (!key_w && !key_s) // the player isn't moving?

                       {

                               ent_animate(my, "stand", anim_percentage, ANM_CYCLE); // play the "stand" animation

                       }

                       else // the player is moving?

                       { 

                               ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // play the "walk" animation

                       }

                       anim_percentage += 5 * time_step; // 5 = animation speed

                       jump_percentage = 0; // always start jumping with the first frame

               }

            else // the player is jumping

            {

                    jump_percentage += 5 * time_step; // 5 = jump animation speed

                       ent_animate(my, "jump", jump_percentage, ANM_CYCLE); // play the "jump" animation

               }

 

               // camera code

               camera.x = player.x - 250 * cos(player.pan);

               camera.y = player.y - 250 * sin(player.pan); // use the same value (250) here

               camera.z = player.z + 150; // place the camera above the player, play with this value

               camera.tilt = -20; // look down at the player

               camera.pan = player.pan;

               wait (1);

       }

}


you can see how that movement code and such is written, but how to bind it to a single jump command and not with the move keys inside the if !jump_height to make it work


New to lite-c and gamestudio in general, thank you for reading.
Com, A7 v7.7
Re: problem with jump function [Re: Darkyyes] #248482
01/27/09 04:23
01/27/09 04:23
Joined: Jun 2007
Posts: 152
Norway
D
Darkyyes Offline OP
Member
Darkyyes  Offline OP
Member
D

Joined: Jun 2007
Posts: 152
Norway
EDIT: ok got it to work for a brief second, then didnt change any code then ran my project again but then the screen was totally black except for my player model

EDIT: now I cant get it working like I first did, even though I do exactly the same thing as I did first :S

EDIT: I decided to port over KH movement instead. it worked flawlessly after I made it fit to my camera settings

Last edited by Darkyyes; 01/27/09 05:50.

New to lite-c and gamestudio in general, thank you for reading.
Com, A7 v7.7

Moderated by  George 

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