Jump to content


rhasta

Member Since 29 Jul 2010
Offline Last Active Feb 13 2011 04:13 AM

Posts I've Made

In Topic: Game Maker Contest 2011 By Team Dark Tomorrow

12 February 2011 - 11:38 PM

def. gonna hop in this contest haha. I be bringin my one and only game made in GameMaker.

In Topic: T.D. tower button canceling issue

11 November 2010 - 06:19 AM

c_raethke you are awesome. You helped me fix my issue. Tanks for the help mon. Much appreciated.

In Topic: T.D. tower bullet image problem

11 November 2010 - 01:19 AM

Dr. Zeus you came through again!lol Tanks again. My other problem was that I had the code in the create event for the object. But i created a step event and put it in there. I did not do the if statements, I used switch case but you still helped me fix this tormenting issue of mine. I already got you in my credits in the game haha. I'll let yea know as soon as i get done with the game.

In Topic: T.D. tower bullet image problem

11 November 2010 - 12:26 AM

Information about object: obj_tower

Sprite: tower_sprite
Solid: false
Visible: true
Depth: -2
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Create Event:
execute code:

// These variables control the tower

{
active = 1; // indicates whether the tower should fire or not
firing = 0; // indicates firing sequence
target = noone; // indicates target instance
range = 115; // indicates range
rate = 1; // indicates firing rate
damage = 19; // indicates damage
price = 20;
name = 'EaRtH Tower';
coll_path = 0; // indicates a possible collision
selected = 0; // indicates whether selected
level = 1; // indicated the level of the tower
}


Step Event:
if active is equal to 0
jump to position (mouse_x,mouse_y)
align position to a grid with cells of 16 by 16 pixels
execute code:

//Check if enemies are in range and activate firing if needed

{
var ii, dist, xx, yy;
if firing > 0 firing += 1;
if firing >= 30/rate firing = 0;
if not instance_exists(target) target = noone;
if instance_exists(obj_enemy)
{
if target = noone target = instance_nearest(x,y,obj_enemy);
if point_distance(x,y,target.x,target.y) > range
target = noone;
else if firing = 0
{
firing = 1;
//Create a bullet
ii = instance_create(x,y,obj_bullet);
dist = point_distance(x,y,target.x,target.y)/24;
xx = target.x+target.path_speed*dist*cos(target.direction*pi/180);
yy = target.y-target.path_speed*dist*sin(target.direction*pi/180);
ii.speed = 24;
ii.direction = point_direction(x,y,xx,yy);
ii.damage = damage;
}
}
}


Begin Step Event:
if expression collision_rectangle(x-16,y-16,x+15,y+15,obj_path_marker,0,1) is not true
if expression collision_rectangle(x-16,y-16,x+15,y+15,obj_tower,0,1) is not true
if expression collision_rectangle(x-16,y-16,x+15,y+15,obj_rock,0,1) is not true
set variable coll_path to 0
execute code:

// Check for collisions

{
if !collision_rectangle(x-16,y-16,x+15,y+15,obj_path_marker,0,1)
if !collision_rectangle(x-16,y-16,x+15,y+15,obj_tower,0,1)
if !collision_rectangle(x-16,y-16,x+15,y+15,obj_rock,0,1)
coll_path = 0;
}


Collision Event with object obj_tower:
set variable coll_path to 1

Collision Event with object obj_path_marker:
set variable coll_path to 1

Collision Event with object obj_rock:
set variable coll_path to 1

Mouse Event for Left Pressed:
execute code:

// Select the tower or activate it

{
if active = 1
if selected = 0
{
obj_tower.selected = 0;
selected = 1;
controller.ii_select = instance_position(x,y,obj_tower);
draw_set_color(c_white);
draw_circle(x,y,range,1);
draw_set_alpha(1);
}
if active = 0
if coll_path = 0
{
active = 1;
controller.money -= price;
}
}


Draw Event:
if active is equal to 0
execute code:

//Draw a ghost of the tower and its range

{
draw_set_alpha(0.6);
if coll_path = 0 draw_set_color(c_green);
else draw_set_color(c_red);
draw_circle(x,y,16,0);
draw_set_color(c_white);
draw_circle(x,y,range,1);
draw_set_alpha(1);
}

else
execute code:

// Draw the sprite
{
draw_sprite(sprite_index,0,x,y);
draw_set_alpha(0.9);

switch (level)
{
case 2: draw_sprite(sprite_index,1,x,y); break;
case 3: draw_sprite(sprite_index,2,x,y); break;
case 4: draw_sprite(sprite_index,3,x,y); break;
case 5: draw_sprite(sprite_index,4,x,y); break;
}

if selected = 1
{
draw_set_color(c_white);
draw_circle(x,y,range,1);
draw_text(x,y,level);
}
}





Information about object: obj_bullet


Sprite: bullet_sprite
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Create Event:
execute code:

//initialize damage
{
damage = 2;
image_speed = 0;
image_index = 0;
}

if obj_tower.level is equal to 2
execute code:

image_index = 1

if obj_tower.level is equal to 3
execute code:

image_index = 2

if obj_tower.level is equal to 4
execute code:

image_index = 3

if obj_tower.level is equal to 5
execute code:

image_index = 4


Collision Event with object obj_enemy:
execute code:

//damage the enemy and explode
{
other.own_health -= damage;

instance_destroy();
}


Other Event: Outside Room:
execute code:

// Destroy the instance

instance_destroy();

In Topic: T.D. tower button problem

03 September 2010 - 06:25 AM

Thank alot JWRAC I now understand switch statements! Seems so simple now haha. Wish I could help you on the array problem but I have never tried to used one in gamemaker