Jump to content


Photo

Drawing an image for every value of a variable


  • Please log in to reply
8 replies to this topic

#1 trivettz

trivettz

    GMC Member

  • New Member
  • 17 posts
  • Version:GM8

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.
  • 0

#2 Popcorn123

Popcorn123

    JNC Games Creator

  • GMC Member
  • 395 posts
  • Version:GM:Studio

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

  • 1

#3 trivettz

trivettz

    GMC Member

  • New Member
  • 17 posts
  • Version:GM8

Posted 04 March 2012 - 01:45 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

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?
  • 0

#4 Popcorn123

Popcorn123

    JNC Games Creator

  • GMC Member
  • 395 posts
  • Version:GM:Studio

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
  • 0

#5 trivettz

trivettz

    GMC Member

  • New Member
  • 17 posts
  • Version:GM8

Posted 04 March 2012 - 01:55 AM

Oh...sorry. Try this:

draw_sprite(bullet,var,x,y)
then just use the same code for the button

Nope, this didn't work. Oh well, I'll just do it the long way. Thank you very much for helping me.
  • 0

#6 Popcorn123

Popcorn123

    JNC Games Creator

  • GMC Member
  • 395 posts
  • Version:GM:Studio

Posted 04 March 2012 - 01:57 AM

no prob
  • 0

#7 trivettz

trivettz

    GMC Member

  • New Member
  • 17 posts
  • Version:GM8

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.
  • 0

#8 Popcorn123

Popcorn123

    JNC Games Creator

  • GMC Member
  • 395 posts
  • Version:GM:Studio

Posted 04 March 2012 - 02:25 AM

you can try :thumbsup:
  • 0

#9 trivettz

trivettz

    GMC Member

  • New Member
  • 17 posts
  • Version:GM8

Posted 04 March 2012 - 03:21 AM

you can try :thumbsup:


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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users