Jump to content


Photo

One of my Objects crashes the game


  • Please log in to reply
7 replies to this topic

#1 Dudemonicon

Dudemonicon

    GMC Member

  • New Member
  • 19 posts
  • Version:GM8

Posted 09 February 2012 - 04:58 PM

Im making a Plants vs Zombies game. and My "Tank" zombie has issues. He takes up 3x2 tiles (a tile is 50x69 pixels) and the spawn region is 2 tiles to the right of the field. I have to spawn him partially on the field so he doesnt start off screen and crash the game. But when he spawns, if there are not 2 of the 5 tiles empty on the first column, the game crashes. no error reports, it just stops. Here is the tanks info:

Information about object: obj_tank

Sprite: tank
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: obj_zombie_parent
Mask: <same as sprite>

Create Event:
start moving in directions 000100000 with speed set to 0.15
execute code:
shealth=250
only = false
alarm[0]=200
//in the mouse left press event use this code
do move_random(489,69) until self.x <800 and self.y >34 and self.y <320 and self.x >200

//in the step event use this code



Alarm Event for alarm 0:
execute code:
instance_create(x,y,obj_tshot)
alarm[0]=200

Step Event:
execute code:

if shealth <= 0
{
instance_destroy()
global.cash+=500
}


Collision Event with object obj_shot:
execute code:
// Destroy itself, then add 1 Exp, and add 5 money.
 shealth -= 2

for other object: destroy the instance

Collision Event with object obj_tower_parent:
for other object: destroy the instance

Collision Event with object obj_mower:
set variable shealth relative to -150
for other object: destroy the instance

Collision Event with object obj_explode:
set variable shealth relative to -100

Collision Event with object obj_uvshot:
execute code:
// Destroy itself, then add 1 Exp, and add 5 money.
 shealth -= ((global.money * 4) / 1000)

for other object: destroy the instance

Collision Event with object obj_smexplode:
set variable shealth relative to -100

Draw Event:
execute code:
draw_sprite_ext(tank,0,x,y,1,1,image_angle,self,1)

  draw_healthbar(x+30,y+118,x+120,y+128,((shealth/250)*100),c_black,c_red,c_lime,0,true,true)

  • 0

#2 white_boi

white_boi

    GMC Member

  • New Member
  • 44 posts
  • Version:GM8

Posted 09 February 2012 - 05:04 PM

wow... your code is a bit confusing can you possibly post up a GMK file so i can get a better look at it?
  • 0

#3 flxp

flxp

    GMC Member

  • GMC Member
  • 325 posts
  • Version:GM8

Posted 09 February 2012 - 06:09 PM

well are you using arrays? (as in for the Tiles)

if you are you need to precisely check for all the boundary of the array for it not to crash the game
  • 0

#4 Silver Scratch

Silver Scratch

    GMC Member

  • GMC Member
  • 166 posts
  • Version:GM8

Posted 09 February 2012 - 08:50 PM

I'm making a PVZ game too! But it seems that yours will be better than mine. Anyway i'm using a very different proccess. Since i'm not a pro, i make an instance for each row, example:
ObjZom_NormalP1
after that, he only walks in the first top horizontal row. So any other bullets from another row won't hit him. Yes, this is a very slow proccess. If you want to, i can help you with some of PVZ scripts (i do not use D&D's srry :( )
  • 0

#5 Dudemonicon

Dudemonicon

    GMC Member

  • New Member
  • 19 posts
  • Version:GM8

Posted 10 February 2012 - 02:56 AM

I'm making a PVZ game too! But it seems that yours will be better than mine. Anyway i'm using a very different proccess. Since i'm not a pro, i make an instance for each row, example:
ObjZom_NormalP1
after that, he only walks in the first top horizontal row. So any other bullets from another row won't hit him. Yes, this is a very slow proccess. If you want to, i can help you with some of PVZ scripts (i do not use D&D's srry :( )


Mine has been coming along nicely. Until this crash appeared. my positioning system is simply to move_snap randomly. Its worked excellent so far. Sorry for my code BTW.. I rewrite alot and leave stuff there. Im also very novice so i over complicate things. Hey, Silver Scratch, want to swap executables?
  • 0

#6 Dudemonicon

Dudemonicon

    GMC Member

  • New Member
  • 19 posts
  • Version:GM8

Posted 10 February 2012 - 03:01 AM

The issue Im facing is that the Tank object ignores any rows that have a plant in the last column. It'll automatically spawn in the available rows, if there isnt one, it crashes the game. I never told it to do that tho. All zombies share obj_zombie_parent, and plants share obj_plant_parent. tank works fine spawning on top of other zombies even without a parent... just not plants
  • 0

#7 Silver Scratch

Silver Scratch

    GMC Member

  • GMC Member
  • 166 posts
  • Version:GM8

Posted 10 February 2012 - 06:42 PM

Swap? Or maybe use "Polymerazation" and combine the games? I replied your PM! :D
Edit:
I'm too noob for you executable anyway. :(

Edited by Silver Scratch, 10 February 2012 - 06:44 PM.

  • 0

#8 lukew23

lukew23

    GMC Member

  • GMC Member
  • 276 posts
  • Version:Unknown

Posted 10 February 2012 - 07:45 PM

It seems like an infinite loop glitch. Is there an exit to all the loops under all conditions? Because if you have a loop which says (for example)
Do
{
move to next row
}
until (row is free)
then spawn

if no rows are free, there will be an infinite loop. Make sure it is count controlled, eg:

var count;
count = 0;
Do
{
move to next row;
count++
}
until( row is free or count >= 10)
then if count < 10 spawn
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users