the entity doesnt appear on the game when we press space bar.

Posted By: DirtyDhan

the entity doesnt appear on the game when we press space bar. - 12/15/10 04:27

..the entity must appear when we press space bar..


function main()
{
screen_size.x = 800;
screen_size.y = 600;
screen_color.blue = 150;
level_load("");
//ent_create ("2.mdl", vector (1000, 50, -40), NULL);
}


function none() {
my.ambient = 50;
my.lightrange = 300;
vec_set(my.blue,vector(255,50,50));
set(me,BRIGHT);

vec_scale(my.scale_x,0.15);

my.STATE = 1;
}


function go()
{
my.STATE = 1;
while (1)
{
if(my.STATE == 1)
{
if(key_space)
my.STATE = 2; }
if(my.STATE==2) { ent_createlocal("2.mdl",vector(1000,50,-40), none);
my.STATE = 3;
}
if (my.STATE == 3)
{
if (!key_space)
my.STATE = 1;
}
wait(1);
}
}




..if you will able to reply i will appreciate your effort..
..thanks..
Posted By: 3dgs_snake

Re: the entity doesnt appear on the game when we press space bar. - 12/15/10 04:57

Hi,

Do you want to create entity when you hit space bar or do you want to show it? In your code, you have 2 functions that use the "my" pointer, you must call them in an entity function.

Best regards.
Posted By: MrGuest

Re: the entity doesnt appear on the game when we press space bar. - 12/15/10 13:15

Originally Posted By: 3dgs_snake
Hi,

Do you want to create entity when you hit space bar or do you want to show it? In your code, you have 2 functions that use the "my" pointer, you must call them in an entity function.

Best regards.
The my parameter can only be used in a function called when creating the entity or with its action set in WED, then any subsequent functions called by these will also retain the my pointer

try something like
Code:
#include <acknex.h>
#include <default.c>

action none(){
	
	my.ambient = 50;
	my.lightrange = 300;
	vec_set(my.blue,vector(255,50,50));
	set(me,BRIGHT);
	
	vec_scale(my.scale_x,0.15);
}

void create_entity(){
	
	ent_create("2.mdl", vector(1000, 50, -40), none);
}

function main()
{
	video_mode = 7; //sets video to 800x600 (which is already default)
	
	screen_color.blue = 150; //is useless, loading a level doesn't display any screen color
										//use sky_color to change this
	level_load(NULL);
	
	on_space = create_entity;
}

this will allow you to keep pressing space to create entities

if you only want to be able to create one either do this by:
creating a variable for storing if the entity has been created
or
set on_space to NULL

hope this helps
© 2023 lite-C Forums