• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Adding light to new object - Using Fake Light

W

warbo

Guest
So i have gone and used the "Fake Light" examples in my game and i have got it all working but what i am struggling to do is create a new instance of this light on to a bullet when it is fired.

Currently i have it set up so it's on one bullet out of 5 fired.


HTML:
for (i=0; i<=bbb; i+=1)//Now we're looping through all our circles. From the larger to the smaller.
{
    draw_circle(oPSpaceShip.x-view_xview[0], oPSpaceShip.y-view_yview[0], (aaa-(aaa/bbb*i)), false)
   
    if(object_exists(oBullet)){
        aaa=50
        with (oBullet)
        draw_circle(oBullet.x-view_xview[0], oBullet.y-view_yview[0], (aaa-(aaa/bbb*i)), false)
    }
}
What would i need to change to get it on all current "active" bullets
 

jo-thijs

Member
2 Things:

1) object_index checks if an object exists.
Since oBullet is an object that never gets deleted, this will always be true, regardless of whether there is an active instance of oBullet in the room.
For that you would need instance_exists.
But in this case, you don't need to check for that either.
Just leave that check away.

2) If you already use with (oBullet), you're not supposed to prefix the variables thereafter by oBullet,
because that will only select 1 bullet to get the x and y values from and it will always select the same one.
Get rid of every "oBullet.".
 
A

Aura

Guest
First of all, objects are NOT instances. You'd probably want to use instance_exits() instead.

Apart from that, I'd personally do that locally in the bullet object and use bullet states to determine when to show (draw) it (the circle I mean).
 
W

warbo

Guest
First of all, objects are NOT instances. You'd probably want to use instance_exits() instead.

Apart from that, I'd personally do that locally in the bullet object and use bullet states to determine when to show (draw) it (the circle I mean).
Oh bugger it seems i pasted in the code i added to my notepad for reference.
 
Top