Hello I am developing a kind of space invaders, and I have to create a grid for the initial positions of the invaders, and are 55 (11x5).
that's all i'v made at the moment:
lobal
int gfx;
int direzione;
int last_y;
struct posto[55];
int x;
int y;
end
int n;
begin
set_mode(800,480,16); //RISOLUZIONE
//menu(); da aggiungere successivamente e togliere principale inserendolo nel menu
principale();
gfx=load_fpg("\gfx.fpg");
graph=gfx;
write(0,740,470,1,"Earth Ivasion v003");
loop
if(key(_ESC))
break;
end
frame;
end
let_me_alone();
end
process principale()
begin
x=400; y=240; z=10; graph=101;
n=1;
posto[n]=inv_1(x,y);
posto[1].x=236;
posto[1].y=38;
cannon_1(210,400);
loop
frame;
end
end
//---------------------------invaders1
process inv_1(x,y)
begin
graph=1; z=1;
direzione=0;
x=posto[n].x;
y=posto[n].y;
loop
frame;
end
end
I have to assign each posto [55]
an x
a y
and an order number
when I call the process inv_1 ()
I simply assign the number of array
like:
inv_1 (posto [2]);
so it automatically assigns an inv_1 x, n y, and order number
example
posto[1]. x = 200;
posto[1]. y = 50;
posto[1]. n = 1;
i call:
inv_1 (place [1])
and the program spawn inv_1() in the coordinates 200,50
how to do that?
thanx
Could you be a bit more specific? ??? From I understand you have created a structure with two elements (x and y) that stores the invaders' positions. Is it the issue to place the invaders at those positions or how the invader process reads the position table? Your initial design seems to be correctly layed-out.
You could create a for loop that iterates 55 times over the posto struct, and creates a new invaders process in each iteration.
I.e:
For (i=0; i<55; i++)
invader(posto[i].x, posto[i].y);
End
The invader process in a slighlty modified version of "principal", but now like this:
Process invader (x,y);
etc etc
the game should be a kind of tower defense where the player buys the invaders during the rounds with a credit system
when you bought the first 2 invaders
the game will call them:
inv_1 (posto [1]) and inv_1 (posto [2])
the coordinates of spawns are static,
and took from the array posto[]
My intent is to state for each posto[], x and y
depending on which invader buy
his position are take from the array of reference
i make a list of all posto[]x and posto[]y
and when i want the second invaders ill call it using simply a order number
the program will set the x y spawn
oook! iv take the solution!
my problem was how i call the proces inv_1()
i need to call in reference to posto[]
like: inv_1(posto[2].x,posto[2].y);
perfect!
global
int gfx;
int direzione;
int last_y;
struct posto[55];
int x;
int y;
end
begin
set_mode(800,480,16); //RISOLUZIONE
//menu(); da aggiungere successivamente e togliere principale inserendolo nel menu
principale();
gfx=load_fpg("\gfx.fpg");
graph=gfx;
write(0,740,470,1,"Earth Ivasion v003");
loop
if(key(_ESC))
break;
end
frame;
end
let_me_alone();
end
process principale()
begin
x=400; y=240; z=10; graph=101;
posto[1].x=236;
posto[1].y=38;
posto[2].x=268;
posto[2].y=38;
inv_1(posto[1].x,posto[1].y);
inv_1(posto[2].x,posto[2].y);
cannon_1(210,400);
loop
frame;
end
end
//---------------------------invaders1
process inv_1(x,y)
begin
graph=1; z=1;
direzione=0;
loop
frame;
end
end
//---------------------------invaders2
process inv_2(x,y)
begin
graph=3; z=1;
loop
//x=x+1;
frame;
end
end
//---------------------------invaders3
process inv_3(x,y)
begin
graph=5;z=1;
loop
//x=x+1;
frame;
end
end
//--------------------------ufo
process ufo(x,y)
begin
graph=7;z=1;
loop
frame;
end
end
//-------------------------cannon
process cannon_1(x,y)
begin
graph=9;z=1;
loop
frame;
end
end
leave topic opened if i found new problem from grid
thanks handsource
Zip, handsource-dyko is right... if you define 2 params in inv_1, you must use inv_1 with 2 params, you can't use it with a struct with 2 members... members aren't params.
Quote from: Zip on July 18, 2012, 04:44:02 PM
oook! iv take the solution!
my problem was how i call the proces inv_1()
i need to call in reference to posto[]
like: inv_1(posto[2].x,posto[2].y);
perfect!
global
int gfx;
int direzione;
int last_y;
struct posto[55];
int x;
int y;
end
begin
set_mode(800,480,16); //RISOLUZIONE
//menu(); da aggiungere successivamente e togliere principale inserendolo nel menu
principale();
gfx=load_fpg("\gfx.fpg");
graph=gfx;
write(0,740,470,1,"Earth Ivasion v003");
loop
if(key(_ESC))
break;
end
frame;
end
let_me_alone();
end
process principale()
begin
x=400; y=240; z=10; graph=101;
posto[1].x=236;
posto[1].y=38;
posto[2].x=268;
posto[2].y=38;
inv_1(posto[1].x,posto[1].y);
inv_1(posto[2].x,posto[2].y);
cannon_1(210,400);
loop
frame;
end
end
//---------------------------invaders1
process inv_1(x,y)
begin
graph=1; z=1;
direzione=0;
loop
frame;
end
end
//---------------------------invaders2
process inv_2(x,y)
begin
graph=3; z=1;
loop
//x=x+1;
frame;
end
end
//---------------------------invaders3
process inv_3(x,y)
begin
graph=5;z=1;
loop
//x=x+1;
frame;
end
end
//--------------------------ufo
process ufo(x,y)
begin
graph=7;z=1;
loop
frame;
end
end
//-------------------------cannon
process cannon_1(x,y)
begin
graph=9;z=1;
loop
frame;
end
end
leave topic opened if i found new problem from grid
thanks handsource
yes.
perfect! iv made 5 cicle for to assign automaticly x and y,
now iv new problem my invaders wont go down!
lets try
ok now the invaders go down !
i'v canghed
struct posto[55];
int x;
int y;
int n;
end
then
for (i=0; i<55; i++)
posto.n=inv_1(posto.x,posto.y);
end
for each posto.n there is an X and an Y
for go down i use another FOR cicle:
for (i=0;i<55;i++)
posto.n.y+=1;
end
and it work propellery