Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 831 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Error Message for 'x' #478245
09/25/19 05:01
09/25/19 05:01
Joined: Sep 2019
Posts: 7
D
Dark_Light Offline OP
Newbie
Dark_Light  Offline OP
Newbie
D

Joined: Sep 2019
Posts: 7
I'm converting the code for the Maniac Miner game from AUM3, and in this function

function player_event()
{
if (event_type == EVENT_ENTITY || event_type == EVENT_PUSH || event_type == EVENT_IMPACT)
{
wait (1);
if (you.skill9 == 1) // collision with a rock or a monster
{
player.x = start_coords.x; // go to starting point
player.y = start_coords.y;
player.z = start_coords.z;
}
}
}

I get the error message "'x'; is not a member of 'function'"

I've been trying to figure out what that could mean, and how to fix it, but I have no idea.

Re: Error Message for 'x' [Re: Dark_Light] #478247
09/25/19 08:17
09/25/19 08:17
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I'm not sure what exactly you made wrong in your code (maybe you have a function which shares the same name with a vector you trying to change ?), but I would recommend not to use those old c-script examples for learning/making games, because they have a lot of troubles in them.. Maniac Miner f.e. has some frame rate independent troubles (movement will work differently on different frame rates etc). If you want to have a good example of gravity code for platformer, take a look at Superku's Tip of the Week series related to gravity.
Tip of the Week #9: Gravity and Jumping? No Problem!

Anyway, I converted the Maniac Miner code for you, added some fixes, but it's not 100% fixed (gravity will give some troubles):
Code
///////////////////////////////////////////////////////////////////////////////////
// Mani(a)c Miner 3D demo 
// developed for the Acknex User Magazine
// try to get the high score = 170
///////////////////////////////////////////////////////////////////////////////////

FONT *comic_font = "comic20.pcx";

STRING *score_string = "Score:";

SOUND* beep_sound = "beep.wav";
SOUND* eatdot_snd = "eatdot.wav";

VECTOR walk_speed; // maniac's speed on xyz at game start	
VECTOR start_coords; // maniac's starting point

var maniac_speed = 16; // default in-game speed on x
var plant_speed = 8; // evil plant's speed

var animation_speed = 7; // maniac's walking animation speed
var stand_speed = 2; // maniac's standing animation speed
var jump_speed = 5; // maniac's jumping animation speed
var jump_height = 40; // default was 50
var jump_time = 1; // decreases while jumping to jump_time = -1

var camera_distance = 900; // play with these values
var camera_height = 200;

var points; // score

PANEL *score_panel =
{
	pos_x = 0;
	pos_y = 0;
	digits(650, 550, 4, comic_font, 1, points);
	flags = SHOW;
}

TEXT *score_text =
{
	pos_x = 470;
	pos_y = 550;
	font = comic_font;	
	string = score_string;
	flags = SHOW;
}

function maniac_event()
{
	if (event_type == EVENT_ENTITY || event_type == EVENT_PUSH || event_type == EVENT_IMPACT)
	{
		if(!player){ return; }
		
		if (you.skill9 == 1) // collision with a rock or a monster
		{
			player.x = start_coords.x; // go to starting point
			player.y = start_coords.y;
			player.z = start_coords.z;
			points = 0; // reset score
			beep(); // code to restart the game, restore the cans, etc goes here
		}
	}
}

function maniac_gravity()
{
	VECTOR temp_vec;
	vec_set (temp_vec, my.x);
	temp_vec.z -= 2000;
	my.skill11 = c_trace(my.x, temp_vec, IGNORE_ME | IGNORE_SPRITES | IGNORE_MODELS | USE_BOX); // get maniac's height above the floor
	if (my.skill11 > 2)  // if I'm in the air
	{
		walk_speed.z -= 2 * time_step; // gravity force pulls me down
	}
	else	
	{	
		walk_speed.z = 0; // if I'm on the ground, why worry
		jump_time = 1; // allow instant jumping after short jumps
	}
	
	if (my.skill11 < 0) // if I'm a little under the ground
	{
		walk_speed.z += 5 * time_step; // pull me out of the ground
	}
}

function maniac_jump()
{
	while (jump_time > -1)
	{
		if (key_space == 0) // allow different jumps depending
		{                   // on how much time "space" has been pressed
			return;
		} 
		walk_speed.z = jump_height * time_step * jump_time;
		jump_time -= 0.075 * time_step; // play with 0.04
		if (jump_time > 0)
		{
			ent_animate(my, "jump", my.skill12, ANM_CYCLE); 
			my.skill12 += jump_speed * time_step; // loop animation       
		}
		draw_text("AAA", 100, 100, COLOR_WHITE);
		wait (1);
	}
	while (key_space == 1) { wait (1); } // wait for space to be released
	jump_time = 1; // allow jumping again
	my.skill12 = 0;  
}

function maniac_moves()
{
	ent_animate(my, "stand", 0, 0); // maniac stands still for now
	
	while (my)
	{
		maniac_gravity(); // gravity force works all the time
		
		if (key_force.x != 0)
		{
			if (key_force.x > 0) 
			{
				player.pan = 0;
			}
			else
			{	
				player.pan = 180;
			}
			
			walk_speed.x = maniac_speed * time_step; // restore speed on x
			
			if(jump_time == 1) // animate if not jumping
			{
				ent_animate(my, "walk", my.skill9, ANM_CYCLE);
				my.skill9 += animation_speed * time_step;   
				if (my.skill9 > 100) { my.skill9 = 0; }  // loop animation 
			}
		}	
		else // maniac stands
		{
			walk_speed.x = 0;
			if(jump_time == 1) // animate if not jumping
			{
				ent_animate(my, "stand", my.skill10, ANM_CYCLE); 
				my.skill10 += stand_speed * time_step;   
				if (my.skill10 > 100) { my.skill10 = 0; }  // loop animation 
			}
		}
		
		if (key_space == 1 && jump_time == 1) // one jumping action at a time, please 
		{
			maniac_jump();
		} 
		
		c_move (my, vector(walk_speed.x, 0, 0), nullvector, IGNORE_YOU | IGNORE_PASSABLE | GLIDE); // move maniac
		
		// added in order to disable jumping when we hit something with our HEAD
		c_move (my, nullvector, vector(0, 0, walk_speed.z), IGNORE_YOU | IGNORE_PASSABLE);
		if(HIT_TARGET)
		{
			if(hit.z > my.z)
			{
				walk_speed.z = 0;
				jump_time = -1;
			}
		}
		
		vec_set(camera.pan, vector(90, 0, 0)); // set and keep the camera position
		vec_set(camera.x, vector(my.x, my.y - camera_distance, my.z + camera_height));  
		
		wait (1);
	}
}

action player_start()
{
	vec_set(start_coords, my.x); // copy player's starting coords
	my.ambient = 100; // make the player bright - looks better
	player = me; // I'm the player
	my.eflags |= FAT | NARROW; // and I'm fat
	vec_set(my.max_x, vector(16, 16, 32));
	vec_set(my.min_x, vector(-16, -16, -32));
	my.emask |= (ENABLE_ENTITY | ENABLE_PUSH | ENABLE_IMPACT); // I react if I collide with entities
	my.event = maniac_event; // and I trigger this event if I meet them
	points = 0; // reset score
	maniac_moves(); // I move, too
}

action rock()
{
	c_setminmax(my);
	my.y = player.y; // make sure they can collide
	my.ambient = 100; // make it bright
	my.skill9 = 1; // for rocks
}

action evil_plant() // free model from Willson Graphics  
{
	c_setminmax(my);
	VECTOR plant_speed_vec;
	vec_fill(plant_speed_vec, 0);
	plant_speed_vec.x = plant_speed;
	my.y = player.y;
	my.ambient = 100;
	my.push = 10; // the maniac (player) has a default push = 0
	my.skill9 = 1; // set this skill for evil plants too
	my.skill1 *= 6; // guess why? (to be honest, this is just bs)
	
	while (my)
	{
		DEBUG_VAR(my.skill1, 0);
		DEBUG_VAR(my.skill20, 20);
		
		c_move (my, vector(plant_speed_vec.x * time_step, 0, 0), nullvector, IGNORE_YOU | IGNORE_PASSABLE);   
		my.skill20 += plant_speed_vec.x;	
		
		if (my.skill20 >= my.skill1 || my.skill20 <= my.skill1 * -1) 
		{
			plant_speed_vec.x *= -1; // change direction
		}
		wait (1);
	}
}

function dot_action() 
{	
	if (event_type == EVENT_IMPACT)
	{
		set(my, INVISIBLE | PASSABLE);
		snd_play(eatdot_snd, 70, 0);
		points += 10;
	}
}

action eat_dots() // eat cola dots 
{
	c_setminmax(my);
	my.y = player.y;
	my.emask |= (ENABLE_IMPACT);
	my.event = dot_action;
}

function curtain_action()
{	
	if (event_type == EVENT_IMPACT)
	{
		while (camera.arc < 140) // zoom out on impact with player = finish
		{
			camera.arc += 0.2 * time_step;
			wait (1);
		}
	}
}

action curtain() // free model from Willson Graphics  
{
	c_setminmax(my);
	my.y = player.y;
	my.emask |= (ENABLE_IMPACT);
	my.event = curtain_action;
}

function main()
{
	video_mode = 7; // 800x600;
	video_depth = 16; // D3D mode
	
	camera.arc = 65; // set field of view
	fps_max = 50; // limit the frame rate	
	level_load ("maniac.wmb"); 
	wait (2); // wait for the level to load
}


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Error Message for 'x' [Re: Dark_Light] #478251
09/25/19 14:31
09/25/19 14:31
Joined: Sep 2019
Posts: 7
D
Dark_Light Offline OP
Newbie
Dark_Light  Offline OP
Newbie
D

Joined: Sep 2019
Posts: 7
Awesome! Thanks so much!

Re: Error Message for 'x' [Re: Dark_Light] #478260
09/26/19 04:12
09/26/19 04:12
Joined: Sep 2019
Posts: 7
D
Dark_Light Offline OP
Newbie
Dark_Light  Offline OP
Newbie
D

Joined: Sep 2019
Posts: 7
EDIT: Nevermind, I just had the model too close to the floor. By raising it up a little, everything is fine. Thank you for your help.

Your code works great, but I can't get the player to jump higher. I change the jump_height number, but the player always jumps the same height. I've been working on it all evening, but I'm sure I'm missing something.

Last edited by Dark_Light; 09/27/19 03:31.

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