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
1 registered members (TedMar), 1,420 guests, and 3 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
Help with collisions #404646
07/12/12 12:11
07/12/12 12:11
Joined: Jul 2012
Posts: 45
G
Gino_Fabrizio Offline OP
Newbie
Gino_Fabrizio  Offline OP
Newbie
G

Joined: Jul 2012
Posts: 45
Hi all, im new here at GameStudio A7 and i liked it so much!! Im starting with a First Person Shooter (for learn more) and i have a few problems and questions.
1) How i can do that the player can climb stairs walking? (normal stairs, size between steps is not huge)...

2) How i can do that the player collide with these stairs? Because firstly he collide and if i still walking against them, he pass through frown

3) How i can do the same that in 2nd question but for jump, because when im under the stairs and i jump, i and i pass through them to be up of them.

4) How i can show a weapon, and not the player model, as Counter Strike and other FPSs, and that weapon fire when shoot, etc..

5) How to add a simple flashlight effect, as Counter Strike have?

6) Sorry for bad english, im south american xD and thanks for reading.

I add my code here:

Code:
#include <acknex.h>
#include <default.c>

ENTITY* Player1;
ENTITY* ent;

var flashlight = 0; // dunno how to do :(
var bullets = 30;
var shotDelay;

BMAP* Crosshair = "crosshair.pcx";
BMAP* weapon = "images\flare0.pcx";
BMAP* bmpAmmo = "images\ammo_hud.tga";

PANEL* mostrar =
{
	digits(5, 5, 5, *, 1, camera.tilt);
	digits(70, 515, 5, "Arial#40b", 1, bullets);
	layer = 100;
	flags = SHOW;
}

PANEL* displayBullets =
{
	pos_x = 5;
	pos_y = 500;
	bmap = bmpAmmo;
	layer = 1;
	flags = SHOW;
}

PANEL* displayCrosshair =
{
	pos_x = 400;
	pos_y = 300;
	bmap = Crosshair;
	flags = SHOW | OVERLAY;
}

PANEL* showWeapon =
{
	pos_x = 0;
	pos_y = 300;
	bmap = weapon;
	flags = SHOW | OVERLAY;
}

void updateCam(ENTITY* ent)
{
	while(1)
	{
		camera.x = ent.x;
		camera.y = ent.y;
		camera.z = ent.z;
		camera.z += 75;
		camera.pan = ent.pan;
		camera.tilt += mouse_force.y*9*time_step;
		if (camera.tilt > 90) 
		{
			camera.tilt = 90;
		}
		else if (camera.tilt < -60)
		{
			camera.tilt = -60;
		}
		wait(1);
	}
}
action playerMovement()
{
	//Parameter
	var movespeed = 70.0/16.0;
	var turnspeed = 10;
	var fallacc = 3.68; // "Gravedad"
	var jumpacc = 20;
	
	//Animations
	var anim_percent = 0;
	var attack_percent = 0;
	var stand_percent = 0;
	//Temporäres
	VECTOR movedir;
	vec_set(movedir, vector(0, 0, 0));
	ANGLE rotdir;
	vec_set(rotdir, vector(0, 0, 0));
	var grounddist;
	
	//Ermitteln der Playerhöhe
	c_setminmax(my);
	wait(1);
	var feedheight = -my.min_z;
	
	//Anpassen der Boundingbox
	my.min_x *= 0.7;
	my.min_y *= 0.8;
	my.min_z = 0;
	my.max_x *= 0.7;
	my.max_y *= 0.8;
	my.max_z *= 0.8;
	//move_friction = 0.5;
	//Starten der Kamerafunktionen
	updateCam(my);
	
	proc_mode = PROC_EARLY;
	while(1)
	{
		//Abfrage der Tasteneingaben
		movedir.x = (key_w-key_s)*(1+key_shift*2);
		if (key_w || key_s)
		{
			anim_percent += 2* movedir.x % 100; // 1.3 = walk cycle percentage per quant
         ent_animate(me,"run",anim_percent,ANM_CYCLE); // play the "walk" animation
		}
		movedir.y = (key_a-key_d * 1.5) * (1 + key_shift);
		if (key_a || key_d)
		{
			anim_percent += 2* movedir.y % 100; // 1.3 = walk cycle percentage per quant
         ent_animate(me,"run",anim_percent,ANM_CYCLE); // play the "walk" animation
		}
		//Abfrage der Mausbewegung
		rotdir.pan = -mouse_force.x;
		
		//Berechnen der Laufgeschwindigkeit
		movedir.x *= movespeed*time_step;
		movedir.y *= movespeed*time_step;
		
		//Berechnen der Bewegungsgeschwindigkeit
		rotdir.pan *= turnspeed*time_step;
		
		//Rotieren und Bewegen 
		vec_add(my.pan, rotdir);
		c_move(my, vector(movedir.x, movedir.y, 0), nullvector, GLIDE|IGNORE_PASSABLE);
		
		//Check der Distanz zum Boden
		grounddist = c_trace(my.x, vector(my.x, my.y, my.z-10000), IGNORE_ME|IGNORE_PASSABLE)-feedheight;
		if(grounddist > 0 || movedir.z < 0)
		{
			//Fallbeschleunigung
			movedir.z += fallacc*time_step;
		}else
		{
			movedir.z = 0;
		}
		
		//Anwenden der Fallbeschleunigung
		my.z -= minv(movedir.z*time_step, grounddist);
		
		if(grounddist-minv(movedir.z*time_step, grounddist) == 0)
		{
			//Springen
			if(key_space)
			{
				movedir.z = -jumpacc;
			}
		}
		if (mouse_left && bullets > 0 && shotDelay == 0)
		{
			attack_percent += 15 * time_step % 100;
			ent_animate(me,"attack",attack_percent,ANM_CYCLE); // play the "walk" animation
			bullets --;
			shotDelay = 4;
		}
		wait(1);
		if (key_f) 
		{
			if (flashlight == 0) flashlight = 1;
			else flashlight = 0;
		}
		/*if (flashlight == 1)
		{
			vec_set(sun_color, vector(0,0,255));
			sun_light = 1;
			sun_pos.x = Player1.x;
			sun_pos.x = Player1.y;
			sun_pos.z = Player1.z + 15;
			sun_angle.pan = Player1.pan;
			sun_angle.tilt = camera.tilt;
			ent.x = Player1.x;
			ent.y = Player1.y;
			ent.z = Player1.z;
			ent.pan = camera.pan;
			ent.tilt = camera.tilt;
		}
		else
		{
			sun_light = 0;
			sun_pos.z = -99999;
		}*/
		if (!key_any) ent_animate(me,"run", 0, ANM_CYCLE); // play the "walk" animation
		if (shotDelay > 0) shotDelay --;
	}
}

function main()
{
	
	video_mode = 7;
	video_depth = 16;
	video_screen = 1;
	shadow_stencil = 4;
   d3d_autotransparency = 1;
   d3d_antialias = 4;
	level_load("level.wmb");
	ent_createlayer("skycube+6.dds", SKY | CUBE | SHOW, 0);
	wait(3);
	Player1 = ent_create("gangst2.mdl", vector(0, 50, 0), playerMovement);
	ph_setgravity(vector(0,0,-368));
}



Thanks, Bye!

Re: Help with collisions [Re: Gino_Fabrizio] #404672
07/12/12 16:14
07/12/12 16:14
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
While reading some of this questions i ask myself if you ever wrote a single line in sed. ^^
You are asking for a complete game, hard said. No one around will do this for free i guess.

Open Manual:
1) Look at glide, c_move and move_min_z
2) as 1 (maybe look at c_setminmax, c_updatehull, fat,narrow,BOUNCE too)
3) Look at c_trace
5) Adding a flashlight is never "simple" or it looks like sh*
http://www.opserver.de/ubb7/ubbthreads.p...true#Post400350

Starting with an fps is not good...hard job.

Example to 3. Add something like this before your c_move/jump whatever
Code:
c_trace(my.x,vector(my.x,my.y,my.z+100),IGNORE_ME|IGNORE_SPRITES|IGNORE_CONTENT);
 if(trace_hit) 
 {
   _Hit_something_above_my_head_cant_move();
 }



greets

another edit:
http://opserver.de/wiki/index.php?title=Scripts#Player_Movement

Last edited by rayp; 07/12/12 19:03.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Help with collisions [Re: rayp] #404700
07/13/12 00:24
07/13/12 00:24
Joined: Jul 2012
Posts: 45
G
Gino_Fabrizio Offline OP
Newbie
Gino_Fabrizio  Offline OP
Newbie
G

Joined: Jul 2012
Posts: 45
thanks for answering, i will learn more xD

Edit: I read the link you put of flashlight, and i see that i have no solution, because he used A7 and didnt have solution frown it is for A8 frown

Last edited by Gino_Fabrizio; 07/13/12 00:30.
Re: Help with collisions [Re: Gino_Fabrizio] #404706
07/13/12 05:56
07/13/12 05:56
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
(Very) Basic example of 1st person weapon + cam

simple fps cam mod of your script
Code:
void updateCam()
{
	while(1)
	{
		camera.x = Player1.x;
		camera.y = Player1.y;
		camera.z = Player1.z;
		camera.pan  += mickey.x; //play around
		camera.tilt += mouse_force.y*9*time_step;
		wait(1);
	}
}



very basic weapon showing
Code:
void fps_weapon()
{
 set(my,ZNEAR|PASSABLE);
 while(my)
 {
  vec_set(my.x, camera.x);
  vec_set(my.y, camera.y);
  vec_set(my.z, camera.z);
  my.pan = camera.pan;
  if(mouse_left) _fire_the_gun();
  my.skill1 += time_step;
  ent_animate(me, "gun_idle_phase", my.skill1, ANM_CYCLE);
  wait(1);
 }
 ptr_remove(me);
}

var weapon_1=0;
void create_fps_weapon()
{
 if(weapon_1 == 1) return;
 weapon_1 = 1;
 while(!Player1) wait(1); //wait for your player, no player no gun
 ent_create("devastorweapon.mdl", vector(Player1.x, Player1.y, Player1.z), fps_weapon);
}

void main()
{
 on_1 = create_fps_weapon;
 ..
}

peace

edit:
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=343985#Post343985

Last edited by rayp; 07/14/12 19:07.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;

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