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

Legacy GM Request help. Making images cycle.

F

Freedom2Fight

Guest
I've been trying to achieve this:



I can move the images left and right but I'm having trouble making the images to cycle as shown above.

Pressing right key increases the variable [item] and pressing left key decreases [item].

For drawing the images:

Code:
for (i = 0; i < 3; i += 1) 
  {
      draw_sprite(spr_images, list_images[|i + item],550 + (i*120),display_get_gui_height()-50);  
  }
 
A

AttaBoy

Guest
So the white value is the one that's currently selected, and the side values are just the previous/next values?

How I would do it (if you have a set maximum number that won't change) is to have a sprite with all the images you want as subimages, then in the middle draw that sprite with image_index = item. On the left side draw it with image_index= item - 1 and on the right draw it with image_index = item + 1.

You could even add image_blend of gray on the side ones to make it clear which is highlighted. Does this help?
 
F

Freedom2Fight

Guest
Thank you AttaBoy for responding.

What I am trying to do is to make the images go in circles if I keep on pressing right or left.
 

CMAllen

Member
image_index wraps around, exactly as you want. Of course, that only works if all values of image_index are valid. If the list of items only contains some of much broader list of all possible items, you would need to control your item index value manually, using an array that contains a reference to the image_index of however many items are valid.
 
Top