Sprite: Implement wave effect (RGSS2)
This initial implementation emulates the way RMVX splits the sprite into "chunks" of about 8 pixels, which it then scrolls left/right on a vertical sine wave. It even replicates the weird behavior when wave_amp < 0, namely "shrinking" the src_rect horizontally. As with bush_opacity, this effect in combination with rotation will render differently from RMVX.
This commit is contained in:
		
							parent
							
								
									42b10fd2ee
								
							
						
					
					
						commit
						af9039f58d
					
				
					 6 changed files with 346 additions and 21 deletions
				
			
		| 
						 | 
				
			
			@ -68,6 +68,35 @@ DEF_PROP_F(Sprite, Angle)
 | 
			
		|||
 | 
			
		||||
DEF_PROP_B(Sprite, Mirror)
 | 
			
		||||
 | 
			
		||||
#ifdef RGSS2
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(spriteWidth)
 | 
			
		||||
{
 | 
			
		||||
	Sprite *s = getPrivateData<Sprite>(mrb, self);
 | 
			
		||||
 | 
			
		||||
	int value;
 | 
			
		||||
	GUARD_EXC( value = s->getWidth(); )
 | 
			
		||||
 | 
			
		||||
	return mrb_fixnum_value(value);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(spriteHeight)
 | 
			
		||||
{
 | 
			
		||||
	Sprite *s = getPrivateData<Sprite>(mrb, self);
 | 
			
		||||
 | 
			
		||||
	int value;
 | 
			
		||||
	GUARD_EXC( value = s->getHeight(); )
 | 
			
		||||
 | 
			
		||||
	return mrb_fixnum_value(value);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEF_PROP_I(Sprite, WaveAmp)
 | 
			
		||||
DEF_PROP_I(Sprite, WaveLength)
 | 
			
		||||
DEF_PROP_I(Sprite, WaveSpeed)
 | 
			
		||||
DEF_PROP_F(Sprite, WavePhase)
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
spriteBindingInit(mrb_state *mrb)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -95,5 +124,15 @@ spriteBindingInit(mrb_state *mrb)
 | 
			
		|||
	INIT_PROP_BIND( Sprite, Color,     "color"      );
 | 
			
		||||
	INIT_PROP_BIND( Sprite, Tone,      "tone"       );
 | 
			
		||||
 | 
			
		||||
#ifdef RGSS2
 | 
			
		||||
	mrb_define_method(mrb, klass, "width",  spriteWidth,  MRB_ARGS_NONE());
 | 
			
		||||
	mrb_define_method(mrb, klass, "height", spriteHeight, MRB_ARGS_NONE());
 | 
			
		||||
 | 
			
		||||
	INIT_PROP_BIND( Sprite, WaveAmp,    "wave_amp"    );
 | 
			
		||||
	INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
 | 
			
		||||
	INIT_PROP_BIND( Sprite, WaveSpeed,  "wave_speed"  );
 | 
			
		||||
	INIT_PROP_BIND( Sprite, WavePhase,  "wave_phase"  );
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	mrb_define_method(mrb, klass, "inspect", inspectObject, MRB_ARGS_NONE());
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue