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
1 registered members (henrybane), 1,499 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
A newbe question - player walk action #392321
01/21/12 16:58
01/21/12 16:58
Joined: Jan 2012
Posts: 4
A
AdamV Offline OP
Guest
AdamV  Offline OP
Guest
A

Joined: Jan 2012
Posts: 4
Hi All,

I just pretty recently learned about GameStudio and am very excited about it. I have been trying few 3D game engines before, yet none were that close to what I was looking for as A8 is. I love the Lite_C idea being C/C++ developer myself. It is great to have MED and WEB on board too. Way to go!

I downloaded and installed demo of A8 and after spending last 4-5 days getting through tutorials and examples, I am pretty much confused by one thing.

I am sorry if this is a silly question, yet I was unable to find the way to do it using the official tutorials or by looking into samples.

I created a simple room using WED and wanted to test it the way player would do it. From docs I learned I need an action to do the player walk - there is even a sample action available in help. But I am sure I miss something since I do not know how to connect the action to whatever the player object would be.

Here's what I did:
1) (WED) Created a simple box/room and gave it some textures
2) (SED) Created a sample code:
Code:
///////////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>

///////////////////////////////////////////////////////////////////////////////////

action player_walk()
{ 
// if the entity has a non standard size, make sure that the bounding box does not drag along the floor
   if ((my.eflags&FAT) && (my.eflags&NARROW)) // when FAT+NARROW are both set
 		my.min_z *= 0.5;

   var speed_down = 0;   // downward speed by gravity
   var anim_percent = 0; // animation percentage
   VECTOR vFeet;
   vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex

   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);
   }
}


function main()
{
	video_mode = 8;
	level_load ("test2.wmb");
	wait(2); // wait until the level is loaded
}


3) Started the script from SED

After that I can just fly through all of the walls and entities without any usage of the player_walk action.

I am pretty sure I do something wrong or miss something.

Can you please turn and shove me into the right direction I would use to learn more of the GameStudio?

Re: A newbe question - player walk action [Re: AdamV] #392322
01/21/12 17:16
01/21/12 17:16
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
2b) Rightclick into one of WED's views, Add -> Add Model, select a model (f.i. copy one from the templates folder into your project folder). Select the model, click the Behaviour tab. Click the button next to the empty Action field and select player_walk. If the list is empty, go to File -> Map Properties -> Script and select your "sample code" from above. Then repeat the step and assign player_walk. Now save and build your level. Then click Run (that's the 9th button in WED's toolbar) and walk around your level.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: A newbe question - player walk action [Re: Superku] #392323
01/21/12 17:41
01/21/12 17:41
Joined: Jan 2012
Posts: 4
A
AdamV Offline OP
Guest
AdamV  Offline OP
Guest
A

Joined: Jan 2012
Posts: 4
That was a quick and excellent tip Superku! Thank you!

I guess to use first person perspective I need to modify the action script somehow?

Re: A newbe question - player walk action [Re: AdamV] #392324
01/21/12 17:52
01/21/12 17:52
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
You're welcome!
Indeed, the script does not contain camera placement. Add the following lines of code:

At the beginning of your player action, at least before the while loop:
camera.genius = me; // makes the object invisible if the camera is inside its hull

In the loop after your c_move:

vec_set(camera.x,vector(my.x,my.y,my.z+my.max_z*0.9)); // my.max_z*0.9 should be somewhere where his eyes are. you may have to change the factor or even add some quants, f.i. +16
vec_set(camera.pan,my.pan);


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: A newbe question - player walk action [Re: Superku] #392326
01/21/12 18:11
01/21/12 18:11
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline

Expert
Realspawn  Offline

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
on my place you can find easy demos to use they include also
movement and camera views laugh


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Re: A newbe question - player walk action [Re: Superku] #392337
01/21/12 18:53
01/21/12 18:53
Joined: Jan 2012
Posts: 4
A
AdamV Offline OP
Guest
AdamV  Offline OP
Guest
A

Joined: Jan 2012
Posts: 4
thank you Superku once again! laugh


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