!!

Welcome to Save Point!

Formerly known as RMVXP, Save-Point is a game creational forum that aids users in creating games using software like RPG Maker or Game Maker. Support is also available today for members and members can also upload and download resources and scripts to use in their games. If you are new or experienced we welcome you to register.

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[XP Script] XP Wave Effect
zecomeia Offline
Junior Member

**
Posts: 14
Joined: Mar 2010
View My Download Submissions
Thanks: 0
Given 0 thank(s) in 0 post(s)

Save Points: 130sp
Awards:

Gender:
Favorite Maker:
Post: #1
XP Wave Effect

XP Wave Effect
por zecomeia

Introduction

Modifications in Sprite class to use the wave effect of RGSS2.

Features

* Muito fiel ao efeito do RMVX


Screen Shot

[Image: xpeaveeffectss.png]

Download

Demo

Instructions

* Paste the script up of main;
* Use how on RGSS2, if don't know, search for RGSS reference manual in help file of RMVX.

Script

Code:
#========================================
# XP Wave Effect
#----------------------------------------
#by:      zecomeia
#date:    01/03/2010
#for:     RGSS
#version: 1.0
#www.colmeia-do-ze.blogspot.com
#----------------------------------------
=begin
Reproduction of the VX's wave effect
(see the help file of the RPGMaker VX
in the RGSS manual reference topic)
=end

#==============#
# Sprite class #
#==============#
class Sprite
  
  include Math
  
  attr_accessor   :wave_amp
  attr_accessor   :wave_length
  attr_accessor   :wave_speed
  attr_accessor   :wave_phase
  attr_accessor   :temp_bitmap
  
  alias initialize default_initialize rescue nil
  alias default_initialize initialize
  def initialize(viewport=nil)
    @wave_amp = 0
    @wave_length = 180
    @wave_speed = 360
    @wave_phase = 0.0
    default_initialize(viewport)
    @temp_bitmap = nil
  end
  
  alias update default_update rescue nil
  alias default_update update  
  def update()
    # the wave effect only works if wave_amp
    # propertie is a number more than zero
    wave_effect if @wave_amp > 0
    default_update()
  end
  
  # Return the width of image, because when use
  # obj.bitmap.width the value will be more than
  # the original value(because effect)
  def width()
    return (self.bitmap.width - @wave_amp * 2)
  end
    
  #---------------
  # Wave Effect
  #---------------
  def wave_effect()
    return if self.bitmap.nil?
    @temp_bitmap = self.bitmap if @temp_bitmap.nil?
    cw = @temp_bitmap.width + (@wave_amp * 2)
    ch = @temp_bitmap.height
    # Follow the VX wave effect, each horizontal line
    # has 8 pixel of height. This device provides less
    # lag in game.
    divisions = @temp_bitmap.height / 8
    divisions += 1 if @temp_bitmap.height % 8 != 0
    self.bitmap = Bitmap.new(cw, ch)
    for i in 0..divisions
      x = @wave_amp * Math.sin(i * 2 * PI / (@wave_length / 8).to_i + Math.deg_to_rad(@wave_phase))
      src_rect = Rect.new(0, i*8, @temp_bitmap.width, 8)
      dest_rect = Rect.new(@wave_amp + x, i * 8, @temp_bitmap.width, 8)
      self.bitmap.stretch_blt(dest_rect, @temp_bitmap, src_rect)
    end
    # frame rate: VX = 60 | XP = 40
    # wave speed compatibility VX to XP: wave_speed * 60/40
    # then: wave_speed * 1.5
    @wave_phase += @wave_speed * 1.5 / @wave_length
    @wave_phase -= 360 if @wave_phase > 360
    @wave_phase += 360 if @wave_phase < 0
  end
  
end

#=============#
# module Math #
#=============#
module Math
  
  #-------------------------------
  # Conversion Degree to Radian
  #-------------------------------
  def Math.deg_to_rad(deg)
    return (deg * PI) / 180.0
  end
  
end

Credits and Thanks
zecomeia

[Image: 88x31.png]

Scripts RGSS, Resources, Tutorials and Translations by zecomeia is licensed under a
Creative Commons Atribuição-Uso Não-Comercial-Compartilhamento pela mesma Licença 2.5 Brasil License.
Permissions beyond the scope of this license may be available at Santuário RPG Maker
04-03-2010 12:14 AM
Visit this user's website Find all posts by this user Quote this message in a reply
PK8 Offline
I am the enemy. I am the antidote.

*****
Posts: 1,731
Joined: May 2009
View My Download Submissions
Thanks: 25
Given 8 thank(s) in 29 post(s)

Save Points: 8,967sp
Items: (View All Items)
Awards:

Gender: Undisclosed
Favorite Maker: RPG Maker XP
Post: #2
XP Wave Effect

Moving this to the scripts section.

Edit: Haha, I like it! But I get a bit of lag using it. I was trying it out on the title sprite with wave_amp and wave_length set to 320. :P Still, this is pretty cool. :)

Formerly known as Punk.
He Used To Feel Invincible, But Now He Doesn't Feel At All...
04-03-2010 12:15 AM
Find all posts by this user Quote this message in a reply
zecomeia Offline
Junior Member

**
Posts: 14
Joined: Mar 2010
View My Download Submissions
Thanks: 0
Given 0 thank(s) in 0 post(s)

Save Points: 130sp
Awards:

Gender:
Favorite Maker:
Post: #3
XP Wave Effect

Quote:Moving this to the scripts section.
Sorry, I was distracted when I posted the script.

Thanks!
The lag is a really problem, but I don't know how to decrease it and keep the normal operation.
I am free for sugestions ^^

Bye
04-03-2010 02:30 PM
Visit this user's website Find all posts by this user Quote this message in a reply
EJlol Offline
Senior Member

****
Posts: 324
Joined: May 2009
View My Download Submissions
Thanks: 1
Given 2 thank(s) in 1 post(s)

Save Points: 4,194sp
Awards:

Gender: Male
Favorite Maker: RPG Maker XP
Post: #4
XP Wave Effect

only use radians instead of degrees. If you want the user to be able to use degrees, write a setter and a getter that converts it.

Im not sure how optimized the cos() and sin() functions are in ruby. It might be faster if you calc the values of the cos() and sin() when the game starts, and cache it into a table, so that you don't have to calc it every frame update.
04-04-2010 12:35 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Ace Offline
~Requiescat In Pace~

*****
Posts: 856
Joined: Nov 2009
View My Download Submissions
Thanks: 14
Given 1 thank(s) in 8 post(s)

Save Points: 430sp
Items: (View All Items)
Awards:

Gender: Male
Favorite Maker: RPG Maker XP
Post: #5
XP Wave Effect

Nice! and doesn't lag very much for me, just a little bit.
04-04-2010 02:09 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


User(s) browsing this thread:
1 Guest(s)


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
   Sideview Battle System Tankentai XP - Version 2.2xp Victor Sant 22 6,701 03-03-2013 05:37 PM
Last Post: DerVVulfman
   KBlueMage XP kyonides 2 382 12-23-2012 09:58 AM
Last Post: kyonides
   XP Irrlicht hansiec 6 541 11-07-2012 05:08 PM
Last Post: hansiec
   KTimers XP kyonides 2 277 10-31-2012 09:47 PM
Last Post: kyonides
   KMarket XP kyonides 3 461 10-14-2012 06:57 AM
Last Post: kyonides
   EKuip XP kyonides 7 563 10-04-2012 09:08 AM
Last Post: MetalRenard
   Semi Ace Window System XP kyonides 0 400 10-01-2012 11:25 PM
Last Post: kyonides
   Left Behind XP kyonides 0 268 10-01-2012 11:10 PM
Last Post: kyonides
   KChest XP kyonides 2 397 09-10-2012 11:44 AM
Last Post: Narzew
   KTelePort XP kyonides 0 250 08-28-2012 07:46 PM
Last Post: kyonides



 Quick Theme: