Drawing an image for every value of a variable
Started by trivettz, Mar 04 2012 01:04 AM
8 replies to this topic
#1
Posted 04 March 2012 - 01:04 AM
I am trying to draw an image for every bullet left in my magazine variable. I tried to use the action_draw_life_images function, but I don't know the syntax. Nor do I know if I am able to input a different variable other than lives. I would be very thankful for any help resolving this.
#2
Posted 04 March 2012 - 01:26 AM
just do this:
if var = 5 draw_sprite(bullet,0,x,y) if var = 4 draw_sprite(bullet,1,x,y) if var = 3 draw_sprite(bullet,2,x,y) if var = 2 draw_sprite(bullet,3,x,y) if var = 1 draw_sprite(bullet,4,x,y) if var = 0 draw_sprite(bullet,5,x,y)Then with the button you use to shoot with:
var -= 1
#3
Posted 04 March 2012 - 01:45 AM
Thank you, this did work, but is there any better way that takes up less memory. Such as some sort of function I can use?just do this:
if var = 5 draw_sprite(bullet,0,x,y) if var = 4 draw_sprite(bullet,1,x,y) if var = 3 draw_sprite(bullet,2,x,y) if var = 2 draw_sprite(bullet,3,x,y) if var = 1 draw_sprite(bullet,4,x,y) if var = 0 draw_sprite(bullet,5,x,y)Then with the button you use to shoot with:var -= 1
#4
Posted 04 March 2012 - 01:47 AM
Oh...sorry. Try this:
draw_sprite(bullet,var,x,y)then just use the same code for the button
#5
Posted 04 March 2012 - 01:55 AM
Nope, this didn't work. Oh well, I'll just do it the long way. Thank you very much for helping me.Oh...sorry. Try this:
draw_sprite(bullet,var,x,y)then just use the same code for the button
#6
Posted 04 March 2012 - 01:57 AM
no prob
#7
Posted 04 March 2012 - 02:17 AM
no prob
I just had a really good idea. Maybe I could try and do an assignment operator and just be like for every instance in the variable add 1, then add a multiplyer for how many pixels I want in between.
#8
Posted 04 March 2012 - 02:25 AM
you can try
#9
Posted 04 March 2012 - 03:21 AM
you can try
I found something about for statements on oracle's website and used that. The code ended up being:
for (pixel = 0;
pixel<global.clip;
pixel += 1)
{
draw_sprite(sprite1,-1,8+(pixel*8),64)
}Oh! I forgot to mention that it worked.
Edited by trivettz, 04 March 2012 - 03:22 AM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











