Added a new intro animation and re-did the backgrounds
|
@ -34,6 +34,7 @@ require 'app/scenes/main_menu.rb'
|
||||||
require 'app/scenes/paused.rb'
|
require 'app/scenes/paused.rb'
|
||||||
require 'app/scenes/settings.rb'
|
require 'app/scenes/settings.rb'
|
||||||
require 'app/scenes/cube_tube.rb'
|
require 'app/scenes/cube_tube.rb'
|
||||||
|
require 'app/scenes/intro.rb'
|
||||||
|
|
||||||
require 'app/scenes/_list.rb'
|
require 'app/scenes/_list.rb'
|
||||||
require 'app/util/scene.rb'
|
require 'app/util/scene.rb'
|
||||||
|
|
|
@ -6,6 +6,7 @@ module Scene
|
||||||
main_menu: MainMenu,
|
main_menu: MainMenu,
|
||||||
settings: SettingsMenu,
|
settings: SettingsMenu,
|
||||||
paused: PauseMenu,
|
paused: PauseMenu,
|
||||||
cube_tube: CubeTubeGame
|
cube_tube: CubeTubeGame,
|
||||||
|
intro: Intro
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@ class CubeTubeGame < GameplayScene
|
||||||
@start_grid_x = @grid_x
|
@start_grid_x = @grid_x
|
||||||
@start_grid_y = @grid_y
|
@start_grid_y = @grid_y
|
||||||
@bg_x = 0
|
@bg_x = 0
|
||||||
@bg_w = 1335
|
@bg_w = Sprite.for(:tunnel_loop).w
|
||||||
|
|
||||||
@next_piece_box = [2, -9, 7, 7]
|
@next_piece_box = [2, -9, 7, 7]
|
||||||
|
|
||||||
|
@ -62,19 +62,19 @@ class CubeTubeGame < GameplayScene
|
||||||
0, 0, 0
|
0, 0, 0
|
||||||
]
|
]
|
||||||
|
|
||||||
@bg_x += (@level + 1) * 2 unless @gameover
|
@bg_x += (@level + 2) * 2 unless @gameover
|
||||||
@bg_x %= @bg_w if @bg_x >= @bg_w
|
@bg_x %= @bg_w if @bg_x >= @bg_w
|
||||||
|
|
||||||
Sprite.for(:tunnel).render(@args, { x: @bg_x, y: 0, w: @bg_w, h: 720 })
|
Sprite.for(:tunnel_loop).render(@args, { x: @bg_x, y: 0, w: @bg_w, h: 720 })
|
||||||
Sprite.for(:tunnel).render(@args, { x: @bg_x - @bg_w, y: 0, w: @bg_w, h: 720 })
|
Sprite.for(:tunnel_loop).render(@args, { x: @bg_x - @bg_w, y: 0, w: @bg_w, h: 720 })
|
||||||
|
|
||||||
# @grid_y = ((1280 - (@grid_h * @blocksize)) / 2) - 21
|
# @grid_y = ((1280 - (@grid_h * @blocksize)) / 2) - 21
|
||||||
Sprite.for(:train).render(@args, { x: 0, y: @grid_x - 140.75 })
|
Sprite.for(:train).render(@args, { x: 0, y: @grid_x - 140.75 })
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_foreground
|
def render_foreground
|
||||||
Sprite.for(:tracks).render(@args, { x: @bg_x, y: 0, w: @bg_w, h: 720 })
|
Sprite.for(:tracks).render(@args, { x: @bg_x, y: 0, w: @bg_w })
|
||||||
Sprite.for(:tracks).render(@args, { x: @bg_x - @bg_w, y: 0, w: @bg_w, h: 720 })
|
Sprite.for(:tracks).render(@args, { x: @bg_x - @bg_w, y: 0, w: @bg_w })
|
||||||
|
|
||||||
Sprite.for(:train_fore).render(@args, { x: 0, y: @grid_x - 140.75 })
|
Sprite.for(:train_fore).render(@args, { x: 0, y: @grid_x - 140.75 })
|
||||||
end
|
end
|
||||||
|
@ -132,14 +132,10 @@ class CubeTubeGame < GameplayScene
|
||||||
|
|
||||||
screen_s =
|
screen_s =
|
||||||
case (@args.state.tick_count % 32)
|
case (@args.state.tick_count % 32)
|
||||||
when 0..7
|
when 0..7 then :screen_s1
|
||||||
:screen_s1
|
when 8..15 then :screen_s2
|
||||||
when 8..15
|
when 16..23 then :screen_s3
|
||||||
:screen_s2
|
when 24..31 then :screen_s4
|
||||||
when 16..23
|
|
||||||
:screen_s3
|
|
||||||
when 24..31
|
|
||||||
:screen_s4
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Sprite.for(screen_s).render(@args, { x: screen_x, y: screen_y + 10, w: screen_w, h: screen_h + 10 })
|
Sprite.for(screen_s).render(@args, { x: screen_x, y: screen_y + 10, w: screen_w, h: screen_h + 10 })
|
||||||
|
|
93
app/scenes/intro.rb
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# this is the lead-in to the main gameplay
|
||||||
|
class Intro < GameplayScene
|
||||||
|
def initialize(args, opts = {})
|
||||||
|
super
|
||||||
|
|
||||||
|
@train_duration = 200
|
||||||
|
@train_spline = [
|
||||||
|
[1.0, 0.25, 0, 0]
|
||||||
|
]
|
||||||
|
@station_start_w = Sprite.for(:station_start).w
|
||||||
|
@full_station_start_w = Sprite.for(:station_start).w + Sprite.for(:tunnel_loop).w
|
||||||
|
@tracks_w = Sprite.for(:tracks).w
|
||||||
|
|
||||||
|
@leave_duration = 600
|
||||||
|
@leave_spline = [
|
||||||
|
[0, 0, 0.5, 1.0]
|
||||||
|
]
|
||||||
|
reset(args)
|
||||||
|
end
|
||||||
|
|
||||||
|
# called every tick of the game loop
|
||||||
|
def tick(args)
|
||||||
|
@start ||= args.state.tick_count
|
||||||
|
case @state
|
||||||
|
when 0
|
||||||
|
if (args.state.tick_count - @start) > 60
|
||||||
|
@train_start = args.state.tick_count
|
||||||
|
@state += 1
|
||||||
|
end
|
||||||
|
when 1
|
||||||
|
@train_pos = 1280 * args.easing.ease_spline(@train_start, args.state.tick_count, @train_duration, @train_spline)
|
||||||
|
if @train_pos <= 0
|
||||||
|
@state += 1
|
||||||
|
@wait_start = args.state.tick_count
|
||||||
|
end
|
||||||
|
when 2
|
||||||
|
if (args.state.tick_count - @wait_start) > 60
|
||||||
|
@leave_start = args.state.tick_count
|
||||||
|
@state += 1
|
||||||
|
end
|
||||||
|
when 3
|
||||||
|
ease = args.easing.ease_spline(@leave_start, args.state.tick_count, @leave_duration, @leave_spline)
|
||||||
|
@station_pos = @full_station_start_w * ease
|
||||||
|
|
||||||
|
@screen_on = true if ease > 0.75
|
||||||
|
|
||||||
|
if @station_pos >= @full_station_start_w
|
||||||
|
Scene.switch(args, :cube_tube, reset: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Sprite.for(:station_loop).render(args, { x: @station_pos })
|
||||||
|
Sprite.for(:station_start).render(args, { x: @station_pos - @station_start_w })
|
||||||
|
Sprite.for(:tunnel_loop).render(args, { x: @station_pos - @full_station_start_w })
|
||||||
|
|
||||||
|
Sprite.for(:train).render(args, { y: 39.25, x: @train_pos })
|
||||||
|
Sprite.for(:screen).render(args, { x: @train_pos + 1024, y: 270 })
|
||||||
|
|
||||||
|
if @screen_on
|
||||||
|
screen_s =
|
||||||
|
case (args.state.tick_count % 32)
|
||||||
|
when 0..7 then :screen_s1
|
||||||
|
when 8..15 then :screen_s2
|
||||||
|
when 16..23 then :screen_s3
|
||||||
|
when 24..31 then :screen_s4
|
||||||
|
end
|
||||||
|
|
||||||
|
Sprite.for(screen_s).render(args, { x: @train_pos + 1024, y: 270 })
|
||||||
|
end
|
||||||
|
|
||||||
|
Sprite.for(:tracks).render(args, { x: @station_pos })
|
||||||
|
Sprite.for(:tracks).render(args, { x: @station_pos - @tracks_w })
|
||||||
|
Sprite.for(:tracks).render(args, { x: @station_pos - (@tracks_w * 2) })
|
||||||
|
Sprite.for(:train_fore).render(args, { y: 39.25, x: @train_pos })
|
||||||
|
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
# custom logic to reset this scene
|
||||||
|
def reset(args)
|
||||||
|
super
|
||||||
|
@state = 0
|
||||||
|
@start = 0
|
||||||
|
@train_start = 0
|
||||||
|
@wait_start = 0
|
||||||
|
@leave_start = 0
|
||||||
|
@train_pos = 1280
|
||||||
|
@station_pos = 0
|
||||||
|
@screen_on = false
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,7 +7,7 @@ class MainMenu < MenuScene
|
||||||
menu_options = [
|
menu_options = [
|
||||||
{
|
{
|
||||||
key: :start,
|
key: :start,
|
||||||
on_select: ->(iargs) { Scene.switch(iargs, :cube_tube, reset: true) }
|
on_select: ->(iargs) { Scene.switch(iargs, :intro, reset: true) }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: :settings,
|
key: :settings,
|
||||||
|
|
|
@ -36,7 +36,7 @@ module Scene
|
||||||
# if we asked to reset the scene, then do so.
|
# if we asked to reset the scene, then do so.
|
||||||
the_scene.reset(args) if reset
|
the_scene.reset(args) if reset
|
||||||
|
|
||||||
raise FinishTick, 'finish tick early'
|
# raise FinishTick, 'finish tick early'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Change the current scene by pushing it onto the scene stack
|
# Change the current scene by pushing it onto the scene stack
|
||||||
|
|
|
@ -8,7 +8,6 @@ module Sprite
|
||||||
train_fore: SpriteInstance.new({ w: 1894, h: 473, path: 'sprites/train-fore.png' }),
|
train_fore: SpriteInstance.new({ w: 1894, h: 473, path: 'sprites/train-fore.png' }),
|
||||||
screen: SpriteInstance.new({ w: 250, h: 210, path: 'sprites/screen.png' }),
|
screen: SpriteInstance.new({ w: 250, h: 210, path: 'sprites/screen.png' }),
|
||||||
tunnel: SpriteInstance.new({ w: 267, h: 144, path: 'sprites/tunnel.png' }),
|
tunnel: SpriteInstance.new({ w: 267, h: 144, path: 'sprites/tunnel.png' }),
|
||||||
tracks: SpriteInstance.new({ w: 267, h: 144, path: 'sprites/tracks.png' }),
|
|
||||||
pause: SpriteInstance.new({ w: 16, h: 16, path: 'sprites/pause.png' }),
|
pause: SpriteInstance.new({ w: 16, h: 16, path: 'sprites/pause.png' }),
|
||||||
gray: SpriteInstance.new({ w: 176, h: 148, path: 'sprites/box/gray.png' }),
|
gray: SpriteInstance.new({ w: 176, h: 148, path: 'sprites/box/gray.png' }),
|
||||||
black: SpriteInstance.new({ w: 176, h: 148, path: 'sprites/box/black.png' }),
|
black: SpriteInstance.new({ w: 176, h: 148, path: 'sprites/box/black.png' }),
|
||||||
|
@ -25,5 +24,10 @@ module Sprite
|
||||||
screen_s3: SpriteInstance.new({ w: 250, h: 210, path: 'sprites/screen-s3.png' }),
|
screen_s3: SpriteInstance.new({ w: 250, h: 210, path: 'sprites/screen-s3.png' }),
|
||||||
screen_s4: SpriteInstance.new({ w: 250, h: 210, path: 'sprites/screen-s4.png' }),
|
screen_s4: SpriteInstance.new({ w: 250, h: 210, path: 'sprites/screen-s4.png' }),
|
||||||
menu: SpriteInstance.new({ w: 1280, h: 720, path: 'sprites/menu.png' }),
|
menu: SpriteInstance.new({ w: 1280, h: 720, path: 'sprites/menu.png' }),
|
||||||
|
tunnel_loop: SpriteInstance.new({ w: 1358, h: 720, path: 'sprites/tunnel-loop.png' }),
|
||||||
|
tracks: SpriteInstance.new({ w: 1358, h: 55, path: 'sprites/tracks.png' }),
|
||||||
|
station_loop: SpriteInstance.new({ w: 1811, h: 720, path: 'sprites/station-loop.png' }),
|
||||||
|
station_start: SpriteInstance.new({ w: 618, h: 720, path: 'sprites/station-start.png' }),
|
||||||
|
station_end: SpriteInstance.new({ w: 518, h: 720, path: 'sprites/station-end.png' })
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
BIN
sprites/station-end.png
Normal file
After Width: | Height: | Size: 294 KiB |
BIN
sprites/station-loop.png
Normal file
After Width: | Height: | Size: 921 KiB |
BIN
sprites/station-start.png
Normal file
After Width: | Height: | Size: 335 KiB |
Before Width: | Height: | Size: 918 B After Width: | Height: | Size: 18 KiB |
BIN
sprites/tunnel-loop.png
Normal file
After Width: | Height: | Size: 662 KiB |
Before Width: | Height: | Size: 15 KiB |
BIN
wip-assets/sprites/station.pdn
Normal file
BIN
wip-assets/sprites/station.png
Normal file
After Width: | Height: | Size: 564 KiB |