Skip to content

Commit

Permalink
Presentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
victords committed Apr 14, 2022
1 parent ababc6e commit 2cac8fa
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 10 deletions.
Binary file added data/img/other/minigl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions data/text/english.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
powered_by Powered by
game_by A game by
play Play
instructions Instructions
options Options
Expand Down
2 changes: 2 additions & 0 deletions data/text/portuguese.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
powered_by Feito com
game_by Um jogo por
play Jogar
instructions Instruções
options Opções
Expand Down
2 changes: 2 additions & 0 deletions data/text/spanish.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
powered_by Desarrollado con
game_by Un juego de
play Jugar
instructions Instrucciones
options Opciones
Expand Down
11 changes: 6 additions & 5 deletions src/game.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'rbconfig'
require 'fileutils'
require_relative 'presentation'
require_relative 'menu'
require_relative 'basic_mode'
require_relative 'dynamic_mode'
Expand Down Expand Up @@ -65,7 +66,7 @@ def initialize

@font = Res.font(:arialRounded, 24)
@text_helper = TextHelper.new(@font)
@controller = Menu.new
@controller = Presentation.new
end

def play_song(id)
Expand Down Expand Up @@ -122,6 +123,10 @@ def save_scores
end
end

def show_menu(force_main = false)
@controller = Menu.new(@controller.is_a?(StaticMode) && !force_main ? :static_level : :main)
end

def start_basic
@controller = BasicMode.new
end
Expand All @@ -144,10 +149,6 @@ def add_score(table_index, rank, name, score)
save_scores
end

def quit(force_main = false)
@controller = Menu.new(@controller.is_a?(StaticMode) && !force_main ? :static_level : :main)
end

def update
if KB.key_down?(Gosu::KB_LEFT_ALT) && KB.key_pressed?(Gosu::KB_RETURN)
@full_screen = !@full_screen
Expand Down
4 changes: 2 additions & 2 deletions src/game_mode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize
end,
Button.new(585, 201, :exit) do
if @game_over
Game.quit
Game.show_menu
else
@confirmation = :exit
end
Expand All @@ -38,7 +38,7 @@ def initialize
if @confirmation == :restart
start
else
Game.quit
Game.show_menu
end
end,
Button.new(420, 330, :no, true) do
Expand Down
2 changes: 0 additions & 2 deletions src/menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ def initialize(state = :main)
instructions: 5,
high_scores: 5
}

Game.play_song(:spheresTheme)
end

def set_page(state, num)
Expand Down
32 changes: 32 additions & 0 deletions src/presentation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class Presentation
AUTHOR_NAME = 'Victor David Santos'

def initialize
@logo = Res.img(:other_minigl)
@timer = 0

Game.play_song(:spheresTheme)
end

def update
@timer += 1
Game.show_menu if @timer == 440 || Mouse.button_pressed?(:left)
end

def draw
if @timer <= 220
t = [110, @timer].min
w = @logo.width / 2
x = (-w + (t / 110.0) * (SCREEN_WIDTH / 2 + w)).round
alpha = @timer <= 190 ? 255 : 255 - (((@timer - 190) / 30.0) * 255).round
@logo.draw(x - w, (SCREEN_HEIGHT - @logo.height) / 2, 0, 1, 1, (alpha << 24) | 0xffffff)
Game.text_helper.write_line(Locl.text(:powered_by), x, (SCREEN_HEIGHT - @logo.height) / 2 - 40, :center, 0xffffff, alpha)
else
t = [110, @timer - 220].min
w = Game.font.text_width(AUTHOR_NAME) * 1.5 / 2
x = (SCREEN_WIDTH + w - (t / 110.0) * (SCREEN_WIDTH / 2 + w)).round
Game.text_helper.write_line(Locl.text(:game_by), x, SCREEN_HEIGHT / 2 - 40, :center, 0xffffff)
Game.text_helper.write_line(AUTHOR_NAME, x, SCREEN_HEIGHT / 2 - 10, :center, 0xffffff, 255, nil, 0, 0, 0, 0, 1.5, 1.5)
end
end
end
2 changes: 1 addition & 1 deletion src/static_mode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def update
@timer = 120
end
else
Game.quit(true)
Game.show_menu(true)
end
end
return
Expand Down

0 comments on commit 2cac8fa

Please sign in to comment.