Hm, perhaps I should have expressed myself more clear, its not really the collision function of the game I meant with a collision.
Its when place_free(x,y) is not free ( or with other words when there is a place_meeting in stead of a place_free which could be defined a collision )
For example, below is the information taken from the snake object ( which is the enemie that seem most affected with the bug )
I'm going to do another attempt to fix it, but if you see the problem in all of this, help is welcome.
I prefer to make actual progress in place of doing useless attempts to fix things, that last thing tends to irritate me when that happens to often which usually results in me needing a break from the project
Information about object: obj_Snake1
Sprite: sprSnakeR
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: objHurt2
Mask:
Create Event:
execute code:
HP=2
stunned=0
attacking=0
image_speed=0.2
alarm[0]=10
Alarm Event for alarm 0:
execute code:
if(!global.pause && !stunned &&!attacking){
switch floor(random(4)){ //Pick a random number, make it an integer, and see what it is
case 0:
direction=360 //Right
sprite_index=sprSnakeR
break;
case 1:
direction=90 //Up
sprite_index=sprSnakeU
break;
case 2:
direction=180 //Left
sprite_index=sprSnakeL
break;
case 3:
direction=270 //Down
sprite_index=sprSnakeD
break;
}
//Set the speed
speed=floor(random(2))
//Reset the alarm
}
alarm[0]=19+random(26)
if(stunned){
stunned=0
}
Alarm Event for alarm 1:
execute code:
image_alpha=1
Alarm Event for alarm 2:
execute code:
image_blend=c_white
Alarm Event for alarm 3:
execute code:
attacking=0
Step Event:
execute code:
if !place_free(x,y) {speed=0; x=xprevious; y=yprevious}
if(!global.pause){
dif = abs(direction-point_direction(x,y,obj_link.x,obj_link.y))
if dif<5 && !stunned && !attacking{
attacking=1
speed=3
alarm[0]=20
alarm[3]=20
}
if(speed){
image_speed=0.2
}
else{
image_speed=0
}
if place_meeting(x,y,obj_link) && obj_link.usingshield{
if global.facing="U"{
sound_play(Bump)
if(place_free(x,y-5)){
y-=5
}
}
if global.facing="D"{
sound_play(Bump)
if(place_free(x,y+5)){
y+=5
}
}
if global.facing="R"{
sound_play(Bump)
if(place_free(x-5,y)){
x+=5
}
}
if global.facing="L"{
sound_play(Bump)
if(place_free(x+5,y)){
x-=5
}
}
}
if place_meeting(x,y,objFirerod) or place_meeting(x,y,objIcerod) or place_meeting(x,y,objMRod) && image_alpha=1{
sound_play(EHit)
HP-=1
image_alpha=0.75
alarm[1]=10
if direction=90{
if(place_free(x,y+5)){
y+=5
}
}
if direction=270{
if(place_free(x,y-5)){
y-=5
}
}
if direction=360 or direction =0{
if(place_free(x-5,y)){
x-=5
}
}
if direction=180{
if(place_free(x+5,y)){
x+=5
}
}
}
if place_meeting(x,y,objFire) or place_meeting(x,y,objWind)or place_meeting(x,y,Arrow) or place_meeting(x,y,objfirer) or place_meeting(x,y,objHammer)or place_meeting(x,y,objSwordshoot) && image_alpha=1{
sound_play(EHit)
HP-=2
if direction=90{
if(place_free(x,y+5)){
y+=5
}
}
if direction=270{
if(place_free(x,y-5)){
y-=5
}
}
if direction=360 or direction =0{
if(place_free(x-5,y)){
x-=5
}
}
if direction=180{
if(place_free(x+5,y)){
x+=5
}
}
image_alpha=0.75
alarm[1]=10
}
}
if place_meeting(x,y,Explosion) && image_alpha=1{
sound_play(EHit)
HP-=3
if direction=90{
if(place_free(x,y+5)){
y+=5
}
}
if direction=270{
if(place_free(x,y-5)){
y-=5
}
}
if direction=360 or direction =0{
if(place_free(x-5,y)){
x-=5
}
}
if direction=180{
if(place_free(x+5,y)){
x+=5
}
}
image_alpha=0.75
alarm[1]=10
}
if place_meeting(x,y,objicer) && !stunned{
sound_play(EHit)
instance_create(self.x,self.y,objChink)
stunned=1
speed=0
image_speed=0
image_blend=c_blue-150
alarm[0]=180
alarm[2]=180
}
if place_meeting(x,y,objBoomerang) && global.boomerlvl=1 && !stunned{
sound_play(EHit)
instance_create(self.x,self.y,objChink)
stunned=1
speed=0
image_speed=0
image_alpha=0.8
alarm[0]=90
alarm[1]=90
}
if place_meeting(x,y,objBoomerang) && global.boomerlvl=2 && !stunned{
sound_play(EHit)
HP-=1
instance_create(self.x,self.y,objChink)
stunned=1
speed=0
image_speed=0
image_alpha=0.7
alarm[0]=120
alarm[1]=120
}
if HP<=0{
instance_change(objEDie,true)
}
execute code:
if place_meeting(x,y,objSword) or place_meeting(x,y,objSwordCharge) && global.swordlvl=1 && image_alpha=1{
sound_play(EHit)
HP-=1
if direction=90{
if(place_free(x,y+5)){
y+=5
}
}
if direction=270{
if(place_free(x,y-5)){
y-=5
}
}
if direction=360 or direction =0{
if(place_free(x-5,y)){
x-=5
}
}
if direction=180{
if(place_free(x+5,y)){
x+=5
}
}
image_alpha=0.75
alarm[1]=10
}
if place_meeting(x,y,objSwordSpin) && global.swordlvl=1 && image_alpha=1{
sound_play(EHit)
HP-=2
if direction=90{
if(place_free(x,y+5)){
y+=5
}
}
if direction=270{
if(place_free(x,y-5)){
y-=5
}
}
if direction=360 or direction =0{
if(place_free(x-5,y)){
x-=5
}
}
if direction=180{
if(place_free(x+5,y)){
x+=5
}
}
image_alpha=0.75
alarm[1]=10
}
if place_meeting(x,y,objSword) && global.swordlvl=2 && image_alpha=1{
sound_play(EHit)
HP-=2
if direction=90{
if(place_free(x,y+5)){
y+=5
}
}
if direction=270{
if(place_free(x,y-5)){
y-=5
}
}
if direction=360 or direction =0{
if(place_free(x-5,y)){
x-=5
}
}
if direction=180{
if(place_free(x+5,y)){
x+=5
}
}
image_alpha=0.75
alarm[1]=10
}
if place_meeting(x,y,objSwordSpin) && global.swordlvl=2 && image_alpha=1{
sound_play(EHit)
HP-=4
if direction=90{
if(place_free(x,y+5)){
y+=5
}
}
if direction=270{
if(place_free(x,y-5)){
y-=5
}
}
if direction=360 or direction =0{
if(place_free(x-5,y)){
x-=5
}
}
if direction=180{
if(place_free(x+5,y)){
x+=5
}
}
image_alpha=0.75
alarm[1]=10
}
if place_meeting(x,y,objSwordCharge) && global.swordlvl=2 && image_alpha=1{
sound_play(EHit)
HP-=3
if direction=90{
if(place_free(x,y+5)){
y+=5
}
}
if direction=270{
if(place_free(x,y-5)){
y-=5
}
}
if direction=360 or direction =0{
if(place_free(x-5,y)){
x-=5
}
}
if direction=180{
if(place_free(x+5,y)){
x+=5
}
}
image_alpha=0.75
alarm[1]=10
}
if place_meeting(x,y,objSwordCharge) && global.swordlvl=3 && image_alpha=1{
sound_play(EHit)
HP-=5
if direction=90{
if(place_free(x,y+5)){
y+=5
}
}
if direction=270{
if(place_free(x,y-5)){
y-=5
}
}
if direction=360 or direction =0{
if(place_free(x-5,y)){
x-=5
}
}
if direction=180{
if(place_free(x+5,y)){
x+=5
}
}
image_alpha=0.75
alarm[1]=10
}
if place_meeting(x,y,objSwordSpin) && global.swordlvl=3 && image_alpha=1{
sound_play(EHit)
HP-=7
if direction=90{
if(place_free(x,y+5)){
y+=5
}
}
if direction=270{
if(place_free(x,y-5)){
y-=5
}
}
if direction=360 or direction =0{
if(place_free(x-5,y)){
x-=5
}
}
if direction=180{
if(place_free(x+5,y)){
x+=5
}
}
image_alpha=0.75
alarm[1]=10
}
if place_meeting(x,y,objSword) && global.swordlvl=3 && image_alpha=1{
sound_play(EHit)
HP-=4
if direction=90{
if(place_free(x,y+5)){
y+=5
}
}
if direction=270{
if(place_free(x,y-5)){
y-=5
}
}
if direction=360 or direction =0{
if(place_free(x-5,y)){
x-=5
}
}
if direction=180{
if(place_free(x+5,y)){
x+=5
}
}
image_alpha=0.75
alarm[1]=10
}
execute code:
if !stunned && image_alpha=1
{
if direction=90 && place_meeting(x,y-1,objdeepwater) or place_meeting(x,y-1,objlava)or place_meeting(x,y-3,objHole)or place_meeting(x,y-1,objHole2){
y+=2
direction=270
alarm[0]=10
sprite_index=sprSnakeD
}
if direction=270 && place_meeting(x,y+1,objdeepwater)or place_meeting(x,y+1,objlava)or place_meeting(x,y+1,objHole)or place_meeting(x,y+1,objHole2) {
y-=2
alarm[0]=10
direction=90
sprite_index=sprSnakeU
}
if direction=360 or direction=0 && place_meeting(x+1,y,objdeepwater)or place_meeting(x+1,y,objlava)or place_meeting(x+1,y,objHole)or place_meeting(x+1,y,objHole2){
x-=2
alarm[0]=10
direction=180
sprite_index=sprSnakeL
}
if direction=180 && place_meeting(x-1,y,objdeepwater) or place_meeting(x-1,y,objlava)or place_meeting(x-1,y,objHole)or place_meeting(x-1,y,objHole2) {
x+=2
alarm[0]=10
direction=360
sprite_index=sprSnakeR
}
}
execute code:
if stunned or image_alpha<=1
{
if direction=90 && place_meeting(x,y-1,objdeepwater)or place_meeting(x,y-1,objlava) {
x=other.x
y=other.y
instance_change(objDrown,true)
}
if direction=270 && place_meeting(x,y+1,objdeepwater) or place_meeting(x,y+1,objlava) {
x=other.x
y=other.y
instance_change(objDrown,true)
}
if direction=360 or direction=0 && place_meeting(x+1,y,objdeepwater) or place_meeting(x+1,y,objlava){
x=other.x
y=other.y
instance_change(objDrown,true)
}
if direction=180 && place_meeting(x-1,y,objdeepwater) or place_meeting(x-1,y,objlava) {
x=other.x
y=other.y
instance_change(objDrown,true)
}
if direction=90 && place_meeting(x,y-3,objHole)or place_meeting(x,y-1,objHole2){
x=other.x
y=other.y
instance_change(objDrop,true)
}
if direction=270 && place_meeting(x,y+1,objHole)or place_meeting(x,y+1,objHole2) {
x=other.x
y=other.y
instance_change(objDrop,true)
}
if direction=360 or direction=0 && place_meeting(x+1,y,objHole)or place_meeting(x+1,y,objHole2){
x=other.x
y=other.y
instance_change(objDrop,true)
}
if direction=180 && place_meeting(x-1,y,objHole)or place_meeting(x-1,y,objHole2) {
x=other.x
y=other.y
instance_change(objDrop,true)
}
}
End Step Event:
execute code:
vx = 0 //Set up some placeholders to save space
vw = 160
vy = 32
vh = 158
if (x< vx)
{
x=xprevious
y=yprevious
}
else if ((x+sprite_width) > vx+vw)
{
x=xprevious
y=yprevious
}
else if (y< vy)
{
x=xprevious
y=yprevious
}
else if ((y+sprite_height) > vh)
{
x=xprevious
y=yprevious
}
Collision Event with object objMagic:
execute code:
sound_play(EHit)
HP-=2
if direction=90{
if(place_free(x,y+5)){
y+=5
}
}
if direction=270{
if(place_free(x,y-5)){
y-=5
}
}
if direction=360 or direction=0{
if(place_free(x-5,y)){
x-=5
}
}
if direction=180{
if(place_free(x+5,y)){
x+=5
}
}
with other{instance_destroy()}