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
2 registered members (dr_panther, 1 invisible), 643 guests, and 2 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
Need help on another program xD #324261
05/20/10 01:42
05/20/10 01:42
Joined: Sep 2007
Posts: 268
United States
Doof_Guy Offline OP
Member
Doof_Guy  Offline OP
Member

Joined: Sep 2007
Posts: 268
United States
Im stuck on making a program that will tell if 2 objects (in this case .bmp panels) collide and if/when they do both are deleted. The game im working on is a castle defence game where the player drops objects from above and tries to hit the enemies below. Im trying to make it so that when the object dropped hits the enemy, the enemy and dropped object both are deleted (and maybe adds an explosion sprite?). If any one could help me on this, that would be great!

DG


To see what 3d models i have made and animated, see the link to my bloghttp://championsdawn.blogspot.com
Re: Need help on another program xD [Re: Doof_Guy] #324375
05/20/10 15:31
05/20/10 15:31
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Here's a simple method for checking whether or not two panels overlap:

Code:
PANEL* pan_one =
{
  ...
}

PANEL* pan_two =
{
  ...
}

...

if( ( pan_one.pos_x + pan_one.size_x >= pan_two.pos_x ) || ( pan_one.pos_x <= pan_two.pos_x + pan_two.size_x ) ) // overlapping in x dimension
  if( ( pan_one.pos_y + pan_one.size_y >= pan_two.pos_y ) || ( pan_one.pos_y <= pan_two.pos_y + pan_two.size_y ) ) // overlapping in y dimension
  {
    // now we know both panels are overlapping in both the x and y dimension!
    // now destroy panels, etc.
  }



If you have any questions, fire away laugh


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: Need help on another program xD [Re: Redeemer] #324603
05/22/10 02:49
05/22/10 02:49
Joined: Sep 2007
Posts: 268
United States
Doof_Guy Offline OP
Member
Doof_Guy  Offline OP
Member

Joined: Sep 2007
Posts: 268
United States
thanks for the help! (sorry i wasn't able to answer right away...been very busy with school =S)

I tried that, but when i run it, an error comes up saying that 'pos_x is not part of BMAP'

i'll post the program i have written so far, and if it wouldnt trouble you too much to take a look at i would really appreciate if you could help me out with it =D
Quote:
include <acknex.h>
var player_score = 0;
FONT* digital_font = "digital.pcx";

PANEL* main_char=
{
bmap = "enemy_ship1.bmp"; //this is where you write the name of the picture you want for the main character
layer = 11;
pos_x = 0; // x position for the char
pos_y = 100; // y position for the char
flags = SHOW | OVERLAY;
}

function update_player(PANEL *paddle,var paddle_mode,var key) //this function updates the player
{
{

paddle.pos_x += 30*time_step*key;
paddle.pos_x = clamp(paddle.pos_x,0,700);
v = paddle.pos_x;
//printf("%d", v);
}

}

#define USER 1

var mode_player = USER;

BMAP *mybullet = "missile2.bmp";

void run_bullet()
{



PANEL *mypannel = pan_create( "bmap=mybullet; flags=VISIBLE | OVERLAY; pos_y = 130;", 11);
mypannel.pos_x = v+15;






while( mypannel->pos_y < screen_size.y )
{
mypannel->pos_y += 15 * time_step;
wait(1);
}

}

BMAP *myenemy = "ship3.bmp";

void run_enemy()
{

PANEL *mypannel = pan_create( "bmap=myenemy; flags=VISIBLE | OVERLAY; pos_y = 350; pos_x = 790;", 11);



while( mypannel->pos_x < screen_size.x )
{
mypannel->pos_x -= 4 * time_step;
wait(1);
}

}


function main ()
{
//int v;
int enemy_count=0,create_counter=0;

while (enemy_count < 15)
{
update_player(main_char, mode_player, key_d-key_a); // makes d and a the keys to be pressed in order to move the player
wait (1);

create_counter++;


// if (PANEL mybullet.pos_x = PANEL myenemy.pos_x && PANEL mybullet.pos_y = PANEL myenemy.pos_y)
if ((mybullet.pos_x +*/ mybullet.size_x >= myenemy.size_x) || (mybullet.size_x <= /*myenemy.pos_x +*/ myenemy.size_x))
if((mybullet.pos_y +*/ mybullet.size_y >= myenemy.size_y) || (mybullet.size_y <= /*myenemy.pos_y +*/ myenemy.size_y))
{
printf("hit");
}
if (create_counter%600 == 0)
{
run_enemy();
enemy_count++; //

}
if (key_v)
{
if (create_counter%100 == 0)
{

run_bullet();
// run_enemy();
// enemy_count++; //
}
}
else if (key_esc) { sys_exit(NULL); }


}
}



btw thanks for the help so far!


To see what 3d models i have made and animated, see the link to my bloghttp://championsdawn.blogspot.com
Re: Need help on another program xD [Re: Doof_Guy] #324608
05/22/10 09:06
05/22/10 09:06
Joined: Nov 2009
Posts: 89
Germany, NRW
T
TrackingKeks Offline
Junior Member
TrackingKeks  Offline
Junior Member
T

Joined: Nov 2009
Posts: 89
Germany, NRW

BMAP *mybullet = "missile2.bmp";

has to be a PANEL*:
PANEL* mybullet =
{
layer=3;
flags=OVERLAY,SHOW;
bmap="missile2.bmp";
}


Gamestudio: A7.82 Commercial/A8 Commercial
System specs (Laptop):
Windows 7 64bit
DirectX v10.1
Intel Core i7-720QM CPU @ 1,60 GHz
4GB DDR2 Ram
NVIDIA GeForce GT 230M (1024MB)
Re: Need help on another program xD [Re: TrackingKeks] #324749
05/23/10 00:20
05/23/10 00:20
Joined: Sep 2007
Posts: 268
United States
Doof_Guy Offline OP
Member
Doof_Guy  Offline OP
Member

Joined: Sep 2007
Posts: 268
United States
(edit - ok i think i see where i went wrong, i am going to try to work on that, but i am open to suggestions...=D)

(edit 2 - i updated my program, but it still isnt working...im not sure how to globally declare the panel's position...any help on this area will be appreciated)


I tried that, but now if messes up my whole program - I will post what i have tho:

Quote:
#include <acknex.h>
int v, h, k, p, w;
var player_score = 0;
FONT* digital_font = "digital.pcx";

PANEL* main_char=
{
bmap = "enemy_ship1.bmp"; //this is where you write the name of the picture you want for the main character
layer = 11;
pos_x = 0; // x position for the char
pos_y = 100; // y position for the char
flags = SHOW | OVERLAY;
}

function update_player(PANEL *paddle,var paddle_mode,var key) //this function updates the player
{
{

paddle.pos_x += 30*time_step*key;
paddle.pos_x = clamp(paddle.pos_x,0,700);
v = paddle.pos_x;
//printf("%d", v);
}

}

//function delete_enemy
//{

//}
#define USER 1

var mode_player = USER;

//PANEL* mybullet =
//{
//layer=3;
//flags=OVERLAY,SHOW;
//bmap="missile2.bmp";
//}

void run_bullet()
{



PANEL *mybullet = pan_create( "bmap=missile2.bmp; flags=VISIBLE | OVERLAY; pos_y = 130;", 11);
mybullet.pos_x = v+15;

//h = v + 15;

//k = mypanel.pos_y;




while( mybullet->pos_y < screen_size.y )
{
mybullet->pos_y += 15 * time_step;
wait(1);
}

}

//PANEL* myenemy =
//{
//layer=3;
//flags=OVERLAY,SHOW;
//bmap="ship3.bmp";
//}


void run_enemy()
{

PANEL *myenemy = pan_create( "bmap=ship3.bmp; flags=VISIBLE | OVERLAY; pos_y = 350; pos_x = 790;", 11);

//p = mypanel.pos_x;
//w = mypanel.pos_y;

while( myenemy->pos_x < screen_size.x )
{
myenemy->pos_x -= 4 * time_step;
wait(1);
}

}


function main ()
{
//int v;
int enemy_count=0,create_counter=0;

while (enemy_count < 15)
{
update_player(main_char, mode_player, key_d-key_a); // makes d and a the keys to be pressed in order to move the player
wait (1);

create_counter++;



if ((mybullet.pos_x + mybullet.size_x >= myenemy.size_x) || (mybullet.size_x <= myenemy.pos_x + myenemy.size_x))
if((mybullet.pos_y + mybullet.size_y >= myenemy.size_y) || (mybullet.size_y <= myenemy.pos_y + myenemy.size_y))
{
// printf("hit");
}
if (create_counter%600 == 0)
{
run_enemy();
enemy_count++; //

}
if (key_v)
{
if (create_counter%100 == 0)
{

run_bullet();

}
}
else if (key_esc) { sys_exit(NULL); }


}
}





thanks for taking the time to help!

Last edited by Doof_Guy; 05/23/10 02:47.

To see what 3d models i have made and animated, see the link to my bloghttp://championsdawn.blogspot.com
Re: Need help on another program xD [Re: Doof_Guy] #324916
05/23/10 22:14
05/23/10 22:14
Joined: Sep 2007
Posts: 268
United States
Doof_Guy Offline OP
Member
Doof_Guy  Offline OP
Member

Joined: Sep 2007
Posts: 268
United States
bump...im pretty stuck on this...any tips?


To see what 3d models i have made and animated, see the link to my bloghttp://championsdawn.blogspot.com
Re: Need help on another program xD [Re: Doof_Guy] #325068
05/24/10 19:31
05/24/10 19:31
Joined: Sep 2007
Posts: 268
United States
Doof_Guy Offline OP
Member
Doof_Guy  Offline OP
Member

Joined: Sep 2007
Posts: 268
United States
ok, I was able to figure out how to do it. Ill post the program on here incase anyone has trouble doing it too.

Quote:

#include <acknex.h>
int v, h, k, p, w, enemy_pos_x, bullet_pos_y;
var player_score = 0;
FONT* digital_font = "digital.pcx";


PANEL* main_char=
{
bmap = "enemy_ship1.bmp"; //this is where you write the name of the picture you want for the main character
layer = 11;
pos_x = 0; // x position for the char
pos_y = 100; // y position for the char
flags = SHOW | OVERLAY;
}

void run_bullet()
{



PANEL *mybullet = pan_create( "bmap=missile2.bmp; flags=VISIBLE | OVERLAY; pos_y = 130;", 11);
mybullet.pos_x = v+15;
{
while( mybullet->pos_y < screen_size.y )
{
mybullet->pos_y += 15 * time_step;
if((mybullet.pos_y > 300)&&(mybullet.pos_y < 400)&&(mybullet.pos_x > (w-100))&&(mybullet.pos_x < (w+100)))
{
printf("Hit");
}

wait(1);
}
}
}

void run_enemy()
{

PANEL *myenemy = pan_create( "bmap=ship3.bmp; flags=VISIBLE | OVERLAY; pos_y = 350; pos_x = 790;", 11);
{
while( myenemy->pos_x < screen_size.x )
{
myenemy->pos_x -= 4 * time_step;
wait(1);
w= myenemy.pos_x;
}
}
}

function update_player(PANEL *paddle,var paddle_mode,var key) //this function updates the player
{
{

paddle.pos_x += 30*time_step*key;
paddle.pos_x = clamp(paddle.pos_x,0,700);
v = paddle.pos_x;

}

}


#define USER 1

var mode_player = USER;


function main ()
{

int enemy_count=0,create_counter=0;

while (enemy_count < 15)
{
update_player(main_char, mode_player, key_d-key_a); // makes d and a the keys to be pressed in order to move the player
wait (1);

create_counter++;
if (create_counter%600 == 0)
{
run_enemy();
enemy_count++; //

}
if (key_v)
{
if (create_counter%100 == 0)
{

run_bullet();

}

}

else if (key_esc) { sys_exit(NULL); }


}



}



Thanks again for taking the time to help me =].

DG


To see what 3d models i have made and animated, see the link to my bloghttp://championsdawn.blogspot.com

Moderated by  adoado, checkbutton, mk_1, Perro 

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