Gamestudio Links
Zorro Links
Newest Posts
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
3 registered members (AndrewAMD, degenerate_762, ozgur), 1,311 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Whats the problem with this code? Yet another... #386499
11/03/11 21:45
11/03/11 21:45
Joined: Feb 2006
Posts: 124
Dallas,TX
Delirium Offline OP
Member
Delirium  Offline OP
Member

Joined: Feb 2006
Posts: 124
Dallas,TX
Alright I know you're sick of hearing about problems writing
lite-C player walk routines. I just bought A8 commercial and long wistfully for the days of ease writing WDL for A6,A5. I tried suggestions and have sought to use player routines from tutorials, from the built in help, from the wiki. Has anyone ever actually written a working player walk routine in lite C where the character doesn't fall through the floor, float up helplessly or pass through walls? Is there a tutorial series in the AUM magazine that takes you through building a simple game with a walking character? I'll look. In the meantime, here is the code that's currently giving me trouble. The level won't run, stops with an error on while(1) although I think my brackets are all there.....

Code:
action player_walk()
   while (1)
   {
// rotate the player using the [A] and [D] keys      
      my.pan += 5*(key_a-key_d)*time_step; 

// determine the ground distance by a downwards trace
      var dist_down; 
      if (c_trace(my.x,vector(my.x,my.y,my.z-5000),IGNORE_ME | IGNORE_PASSABLE | USE_BOX) > 0)
         dist_down = my.z + vFeet.z - target.z; // get distance between player's feet and the ground
      else
         dist_down = 0;

// apply gravity when the player is in the air
      if (dist_down > 0)  // above floor, fall down with increasing speed
         dist_down = clamp(dist_down,0,accelerate(speed_down,5,0.1));
      else                // on or below floor, set downward speed to zero
         speed_down = 0;

// move the player using the [W] and [S] keys      
      var dist_ahead = 5*(key_w-key_s)*time_step;
      dist_ahead = sign(dist_ahead)*(abs(dist_ahead) + 0.5*dist_down); // adapt the speed on slopes
      c_move(me,vector(dist_ahead,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player

// animate the player according to its moved distance
      if (dist_ahead != 0) // player is moving ahead
      {
         anim_percent += 1.3*dist_ahead; // 1.3 = walk cycle percentage per quant
         ent_animate(me,"walk",anim_percent,ANM_CYCLE); // play the "walk" animation
      }
      else // player stands still
      { 
         anim_percent += 5*time_step; 
         ent_animate(me,"stand",anim_percent,ANM_CYCLE); // play the "stand" animation
      }
      wait(1);
   }



Last edited by JustSid; 11/04/11 08:55.

Learning to write lite-C -- A8 commercial
Re: Whats the problem with this code? Yet another... [Re: Delirium] #386504
11/03/11 22:31
11/03/11 22:31
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
You don't have any bracket before the while, after the function's name

Re: Whats the problem with this code? Yet another... [Re: Pappenheimer] #386506
11/03/11 22:49
11/03/11 22:49
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Originally Posted By: Delirium
Has anyone ever actually written a working player walk routine in lite C where the character doesn't fall through the floor, float up helplessly or pass through walls?

Nah. We've always just called these features. wink

In all seriousness, you're missing two brackets: one at the beginning of the function definition, and the other at the end. laugh

EDIT: Also I suggest that you change that "while(1)" condition to a "while(my)" condition so that your game doesn't crash if/when the entity is removed from the level.

EDIT2: Oh, sorry. You do have the bracket at the end. It's a little hard to tell without any indentations. In the future, could you place any code you have written into some [code] tags?

Last edited by Redeemer; 11/03/11 22:53.

Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: Whats the problem with this code? Yet another... [Re: Redeemer] #386535
11/04/11 11:52
11/04/11 11:52
Joined: Feb 2006
Posts: 124
Dallas,TX
Delirium Offline OP
Member
Delirium  Offline OP
Member

Joined: Feb 2006
Posts: 124
Dallas,TX
Thanks for pointing out what I should have noticed. I used to think I was brilliant. I could program computers to do anything in machine language. My idea of a vacation is still to get a hotel room for a week and take a laptop and some computer manuals. I can't believe how incomprehensible Gamestudio has become. I wish I was a gifted 24 year old C programmer hopped up on energy drinks, then maybe I could do this. I'm good at constructing amazing looking levels, and no good at writing walk routines. If I can just get the walking right, then it will only be one problem at a time adding interactions between the player and objects. Seriously, if anyone knows of the complete code for a simple game example with a working walk routine that runs in A8, please direct me to it. Thank you for your replies. I'll go back and fix the brackets and try this player code again.


Learning to write lite-C -- A8 commercial
Re: Whats the problem with this code? Yet another... [Re: Delirium] #386536
11/04/11 11:55
11/04/11 11:55
Joined: Aug 2009
Posts: 1,438
Spain
painkiller Offline
Serious User
painkiller  Offline
Serious User

Joined: Aug 2009
Posts: 1,438
Spain
you can try the shooter template from latest aum 103, you can use that script to try your own levels, and don't forget to keep checked the flag "create meshes" in the map compiler


3D Gamestudio A8 Pro
AMD FX 8350 4.00 Ghz
16GB RAM
Gigabyte GeForce GTX 960 4GB
Re: Whats the problem with this code? Yet another... [Re: painkiller] #386549
11/04/11 17:41
11/04/11 17:41
Joined: Feb 2006
Posts: 124
Dallas,TX
Delirium Offline OP
Member
Delirium  Offline OP
Member

Joined: Feb 2006
Posts: 124
Dallas,TX
Thank you for the idea to download Aum 103 again and use the shooter code. I d forgotten when I first tried that, the player actually did walk through correctly. I do get an error tho which brings to running game to a crash, when I press space and jump. Before, I download that code/demo and when I used it for my own constructed level, that's when I started flying up, up and away. I'll cautiously try remodeling it.

Added by edit: Here is a video I made using A6 and fraps.
http://www.youtube.com/user/masterdelirium#p/a/u/1/U0rjvE2WFPI

I was going to make an entire film but got bogged down making the animated characters. Its kind of corny but "Dr. Frankenstein's village" was very detailed. The Cathedral front was good and I even had a nice funeral procession with the free Max Payne mdl's carrying the coffin. I no longer use the "Master Delirium" name on you tube as someone else uses something identical. I include this link just to show I'm not totally clueless about Gamestudio.

Last edited by Delirium; 11/04/11 17:59.

Learning to write lite-C -- A8 commercial

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