Skip to content

Commit

Permalink
added intro and fades
Browse files Browse the repository at this point in the history
  • Loading branch information
Dahrkael committed Aug 21, 2009
1 parent 1bd630b commit c91e6ed
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 23 deletions.
74 changes: 55 additions & 19 deletions Effects.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,61 @@
module Effects
def self.fade_in
@opacity = 255
@color = Color.new(@opacity, 0, 0, 0)
@fade = $window.draw_quad(0, 0, @color, 640, 0, @color, 0, 480, @color, 640, 480, @color, 500)
for i in 1...255
@opacity -= 1
@color = Color.new(@opacity, 0, 0, 0)
@fade = $window.draw_quad(0, 0, @color, 640, 0, @color, 0, 480, @color, 640, 480, @color, 500)

include Gosu

class Transition
attr_reader :screen_x
attr_reader :screen_y
attr_reader :mapa
def initialize(scene, type, map)
@next_scene = scene
@map = map
@time = 0
@fading = type
@fade_time = 255 if @fading == :in
@fade_time = 0 if @fading == :out
@color = Color.new(@fade_time, 0, 0 ,0)

if @map == true
@mapa = @next_scene.mapa
@screen_x = [[@next_scene.hero.x - 320, 0].max, @next_scene.mapa.width * 32 - 640].min
@screen_y = [[@next_scene.hero.y - 240, 0].max, @next_scene.mapa.height * 32 - 480].min
end
end
def self.fade_out
@opacity = 0
@color = Color.new(@opacity, 0, 0, 0)
@fade = $window.draw_quad(0, 0, @color, 640, 0, @color, 0, 480, @color, 640, 480, @color, 500)
for i in 1...255
@opacity += 1
@color = Color.new(@opacity, 0, 0, 0)
@fade = $window.draw_quad(0, 0, @color, 640, 0, @color, 0, 480, @color, 640, 480, @color, 500)

def button_down(id)
end

def solid_event_infront?(character)
end

def update
@color = Color.new(@fade_time, 0, 0 ,0)
case @fading

when :in
if @fade_time <= 0
$scene = @next_scene
else
@fade_time -= 15 # 15 is cool
end
when :out
if @fade_time >= 255
$scene = @next_scene
else
@fade_time += 15 # 15 is cool
end
end

self.draw
end

def draw

@next_scene.update
$window.draw_quad(0, 0, @color, 640, 0, @color, 0, 480, @color, 640, 480, @color, 500)
end
end

end





1 change: 1 addition & 0 deletions Main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
require 'Window_Steps.rb'
require 'Window_PlayTime.rb'
require 'Window_Location.rb'
require 'Scene_Intro.rb'
require 'Scene_Title.rb'
require 'Scene_Map.rb'
require 'Scene_Menu.rb'
Expand Down
50 changes: 50 additions & 0 deletions Scene_Intro.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
include Gosu

class Scene_Intro
def initialize(window)
#@font = Font.new(window, "Verdana", 18)
@background = Image.new(window, "graphics/gosu-splash.png", true)
@window = window
@time = 0
@fading = :in
@fade_time = 255
@color = Color.new(@fade_time, 0, 0 ,0)
end

def button_down(id)
end

def update
@color = Color.new(@fade_time, 0, 0 ,0)
case @fading

when :in
if @fade_time <= 0
@fading = :wait
else
@fade_time -= 1 # 15 is cool
end
when :wait
@time += 1
if @time >= 200
@fading = :out
end
when :out
if @fade_time >= 255
$scene = Transition.new(Scene_Title.new($window), :in, false)#Scene_Title.new($window)
else
@fade_time += 1 # 15 is cool
end
end

self.draw
end
def draw
@background.draw(0,0,0)
@window.draw_quad(0, 0, @color, 640, 0, @color, 0, 480, @color, 640, 480, @color, 500)
#@font.draw("fade time: "+@fade_time.to_s, 0, 0, 600)
#@font.draw("wait time: "+@time.to_s, 0, 30, 600)
#@font.draw(@fading.to_s, 0, 60, 600)
end

end
2 changes: 1 addition & 1 deletion Scene_Map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def button_down(id)
$temp.actual_map = @mapa.filename
$temp.actual_map_tileset = @mapa.tileset_filename
$temp.actual_position = [@hero.x,@hero.y]
$scene = Scene_Menu.new($window)
$scene = Transition.new(Scene_Menu.new($window), :in, false)
end
end

Expand Down
2 changes: 1 addition & 1 deletion Scene_Menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def button_down(id)
if @command_window.active == true
@command_window.button_down(id)
if id == Button::KbEscape
$scene = Scene_Map.new($window, $temp.actual_map, $temp.actual_map_tileset,$temp.actual_position)
$scene = Transition.new(Scene_Map.new($window, $temp.actual_map, $temp.actual_map_tileset,$temp.actual_position), :in, true)
end
if id == Button::KbReturn
case @command_window.index
Expand Down
2 changes: 1 addition & 1 deletion Scene_Title.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def button_down(id)
$party = Party.new
Database.load_items
$party.setup_initial_party
$scene = Scene_Map.new($window, $initial.map_start, $initial.map_tileset_start, $initial.player_start)
$scene = Transition.new(Scene_Map.new($window, $initial.map_start, $initial.map_tileset_start, $initial.player_start), :in, true)
when 1 # Load Game
Sample.new($window, $initial.buzzer_se).play
# load game
Expand Down
2 changes: 1 addition & 1 deletion Window.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize
self.caption = "RPG Template using Gosu"
@fpscounter = FPSCounter.new(self)
@timer = Timer.new(self)
$scene = Scene_Title.new(self)
$scene = Scene_Intro.new(self)
end

def button_down(id)
Expand Down
Binary file added graphics/gosu-splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c91e6ed

Please sign in to comment.