Jump to content


Photo

Q: Wave


  • Please log in to reply
6 replies to this topic

#1 nekuf

nekuf

    GMC Member

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

Posted 29 March 2016 - 07:51 AM

Hi,

 

im trying to create a wave like effect by creating a certain object in a line of another object

somthing like

instance_create(x, y+irandom_range(-16, 16)*image_yscale, o_dmg);

so it constantly creates o_dmg on a line stretched from the top of the sprite to the bottom of the wave object. and the problem comes when i rotate the wave object. i tryed with len_dir but culd not figure how to use that function in this case. 

overall what im after is to create objects in a line that changes its angle and the origin of that line is in the center.


  • 0

#2 Bojack29

Bojack29

    GMC Member

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

Posted 29 March 2016 - 08:04 AM

Use -dsin.
instance_create(x, y + -dsin(wave) * sprite_height(sprite_index) / 2, obj_whatever);

wave += 10;
Assuming the origin is y centered

Edited by Bojack29, 29 March 2016 - 08:07 AM.

  • 0

#3 nekuf

nekuf

    GMC Member

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

Posted 29 March 2016 - 08:09 AM

i assume wave is the image angle?


  • 0

#4 Bojack29

Bojack29

    GMC Member

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

Posted 29 March 2016 - 08:16 AM

No. Wave is just some integer. Just set it to 0.
  • 0

#5 nekuf

nekuf

    GMC Member

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

Posted 29 March 2016 - 08:19 AM

i dont really understand this code can you explain how it works?


  • 0

#6 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 25708 posts
  • Version:GM:Studio

Posted 29 March 2016 - 08:31 AM

http://gamedevelopme...n--gamedev-6009

 

(some of the images aren't working, but it shouldn't make any difference as the final explanation and GFX to explain are sound)


  • 0

U1FVsm3.png

40799.png


#7 Bojack29

Bojack29

    GMC Member

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

Posted 29 March 2016 - 08:33 AM

dsin navigates some number between -1 and +1. Wave just gives you a consistent wave. It will produce a wave vertically back and forth the height of your sprite
  • 0