Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Making a sinus function?

Hi~ ^^

I have a parallel process to change the opacity of an event. I'd like to change it from 0 to 255 to 0, etc. like a loop. I was thinking, wouldn't this be possible with a sinus math thing, instead of making it with switches, etc. that turn on when it hits 255 so that it goes down instead of up and then off again once it hits 0? And then multiplying the sinus by 255. :3
 
Math.sin(x) => float
Computes the sine of x (expressed in radians). Returns -1..1

Note that you may need to have X/(180/PI) to have X be considered in degrees.

Edit : You will also have to call the opacity change through call script, of course. Look in the interpreter how you can call that.
 
Hi~! Thanks for your reply. ^^

So it would be:

Code:
Math.sin(x) => float

$game_map.events[1].opacity = float

Actually, I'm not quite sure how to work with the x? How will it remember the previous value of x? :s
 

arev

Sponsor

Hi :)
"x" must be changing to get actual sine output. I usually put Graphics.frame_count there, multiplied by some other constant factor to adjust the frequency of the output changes.
[rgss]x=128+128*Math.sin(Graphics.frame_count*0.05)
$game_map.events[1].opacity = x
[/rgss]
You may need to add:
[rgss]attr_accessor :eek:pacity
[/rgss] to Game_Event/Game_Character class for this to work.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top