New train!
This commit is contained in:
parent
ba376238b2
commit
89c7a8116a
8 changed files with 15 additions and 10 deletions
|
|
@ -10,14 +10,14 @@ class CubeTubeGame < GameplayScene
|
||||||
@blocksize = 30
|
@blocksize = 30
|
||||||
@grid_w = 10
|
@grid_w = 10
|
||||||
@grid_h = 20
|
@grid_h = 20
|
||||||
@grid_x = 115
|
@grid_x = 180
|
||||||
@grid_y = ((1280 - (@grid_h * @blocksize)) / 2) + 143
|
@grid_y = ((1280 - (@grid_h * @blocksize)) / 2) - 21
|
||||||
@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 = 1335
|
||||||
|
|
||||||
@next_piece_box = [2, -9.5, 7, 7]
|
@next_piece_box = [2, -9, 7, 7]
|
||||||
|
|
||||||
@sprite_index = [
|
@sprite_index = [
|
||||||
Sprite.for(:black),
|
Sprite.for(:black),
|
||||||
|
|
@ -68,11 +68,15 @@ class CubeTubeGame < GameplayScene
|
||||||
Sprite.for(:tunnel).render(@args, { x: @bg_x, y: 0, w: @bg_w, h: 720 })
|
Sprite.for(:tunnel).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).render(@args, { x: @bg_x - @bg_w, y: 0, w: @bg_w, h: 720 })
|
||||||
|
|
||||||
Sprite.for(:train).render(@args, { x: 0, y: @grid_x - 64 })
|
# @grid_y = ((1280 - (@grid_h * @blocksize)) / 2) - 21
|
||||||
|
Sprite.for(:train).render(@args, { x: 0, y: @grid_x - 140.75 })
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_foreground
|
def render_foreground
|
||||||
Sprite.for(:train_fore).render(@args, { x: 0, y: @grid_x - 64 })
|
Sprite.for(:tracks).render(@args, { x: @bg_x, y: 0, w: @bg_w, h: 720 })
|
||||||
|
Sprite.for(:tracks).render(@args, { x: @bg_x - @bg_w, y: 0, w: @bg_w, h: 720 })
|
||||||
|
|
||||||
|
Sprite.for(:train_fore).render(@args, { x: 0, y: @grid_x - 140.75 })
|
||||||
end
|
end
|
||||||
|
|
||||||
# x and y are positions in the grid, not pixels
|
# x and y are positions in the grid, not pixels
|
||||||
|
|
@ -111,7 +115,7 @@ class CubeTubeGame < GameplayScene
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_next_piece
|
def render_next_piece
|
||||||
screen_x = @grid_y + 400
|
screen_x = @grid_y + 705
|
||||||
screen_y = @grid_x + 80
|
screen_y = @grid_x + 80
|
||||||
screen_w = 250
|
screen_w = 250
|
||||||
screen_h = 200
|
screen_h = 200
|
||||||
|
|
@ -166,7 +170,7 @@ class CubeTubeGame < GameplayScene
|
||||||
(0..@current_piece[x].length - 1).each do |y|
|
(0..@current_piece[x].length - 1).each do |y|
|
||||||
next if @current_piece[x][y].zero?
|
next if @current_piece[x][y].zero?
|
||||||
if (@current_piece_y + y >= @grid_h) ||
|
if (@current_piece_y + y >= @grid_h) ||
|
||||||
((@current_piece_y + y) >= 0 && @grid[@current_piece_x + x][@current_piece_y + y] != 0)
|
((@current_piece_y + y) >= 0 && @grid[@current_piece_x + x][@current_piece_y + y] != 0)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
module Sprite
|
module Sprite
|
||||||
class << self
|
class << self
|
||||||
def reset_all(args)
|
def reset_all(args)
|
||||||
SPRITES.each { |_, v| args.gtk.reset_sprite(v) }
|
SPRITES.each { |_, v| args.gtk.reset_sprite(v.path) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def for(key)
|
def for(key)
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@ module Sprite
|
||||||
# annoying to track but useful for reloading with +i+ in debug mode; would be
|
# annoying to track but useful for reloading with +i+ in debug mode; would be
|
||||||
# nice to define a different way
|
# nice to define a different way
|
||||||
SPRITES = {
|
SPRITES = {
|
||||||
train: SpriteInstance.new({ w: 1597, h: 540, path: 'sprites/train-1.png' }),
|
train: SpriteInstance.new({ w: 1894, h: 473, path: 'sprites/train.png' }),
|
||||||
train_fore: SpriteInstance.new({ w: 1597, h: 540, path: 'sprites/train-2.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' }),
|
||||||
|
|
|
||||||
BIN
sprites/tracks.png
Normal file
BIN
sprites/tracks.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 918 B |
Binary file not shown.
|
Before Width: | Height: | Size: 616 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 171 KiB |
BIN
sprites/train-fore.png
Normal file
BIN
sprites/train-fore.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 292 KiB |
BIN
sprites/train.png
Normal file
BIN
sprites/train.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 647 KiB |
Loading…
Reference in a new issue