From 02572450c7d29353b77dd43b89b2651e21043445 Mon Sep 17 00:00:00 2001 From: Gordon Pedersen Date: Wed, 8 Mar 2023 15:11:59 +1100 Subject: [PATCH] Use scale's reloadable sprites --- app/scenes/cube_tube.rb | 18 +++++++++--------- app/sprite.rb | 26 ++++++++++++++++++-------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/app/scenes/cube_tube.rb b/app/scenes/cube_tube.rb index 67fef63..bbbbeb6 100644 --- a/app/scenes/cube_tube.rb +++ b/app/scenes/cube_tube.rb @@ -34,15 +34,15 @@ class BlockTubeGame ] @sprite_index = [ - "sprites/square/black.png", - "sprites/square/red.png", - "sprites/square/green.png", - "sprites/square/blue.png", - "sprites/square/yellow.png", - "sprites/square/indigo.png", - "sprites/square/violet.png", - "sprites/square/orange.png", - "sprites/square/gray.png", + Sprite.for(:black), + Sprite.for(:red), + Sprite.for(:green), + Sprite.for(:blue), + Sprite.for(:yellow), + Sprite.for(:indigo), + Sprite.for(:violet), + Sprite.for(:orange), + Sprite.for(:gray) ] @grid = [] diff --git a/app/sprite.rb b/app/sprite.rb index 4648aab..7304bde 100644 --- a/app/sprite.rb +++ b/app/sprite.rb @@ -2,14 +2,24 @@ module Sprite # annoying to track but useful for reloading with +i+ in debug mode; would be # nice to define a different way SPRITES = { - bullet: "sprites/bullet.png", - enemy: "sprites/enemy.png", - enemy_king: "sprites/enemy_king.png", - enemy_super: "sprites/enemy_super.png", - exp_chip: "sprites/exp_chip.png", - familiar: "sprites/familiar.png", - player: "sprites/player.png", - pause: "sprites/pause.png", + bullet: 'sprites/bullet.png', + enemy: 'sprites/enemy.png', + enemy_king: 'sprites/enemy_king.png', + enemy_super: 'sprites/enemy_super.png', + exp_chip: 'sprites/exp_chip.png', + familiar: 'sprites/familiar.png', + player: 'sprites/player.png', + pause: 'sprites/pause.png', + gray: 'sprites/square/gray.png', + black: 'sprites/square/black.png', + white: 'sprites/square/white.png', + red: 'sprites/square/red.png', + green: 'sprites/square/green.png', + blue: 'sprites/square/blue.png', + yellow: 'sprites/square/yellow.png', + indigo: 'sprites/square/indigo.png', + violet: 'sprites/square/violet.png', + orange: 'sprites/square/orange.png' } class << self