Last active
May 8, 2019 21:53
-
-
Save wndxlori/fdee58d65070719299a54f6877b61d02 to your computer and use it in GitHub Desktop.
Revisions
-
wndxlori revised this gist
Apr 23, 2019 . No changes.There are no files selected for viewing
-
wndxlori created this gist
Apr 22, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ # the first 2 or 4 values of the primitive conventionally are x, y, (w, h, or x2, y2) # the last 4 values conventionally are r, g, b, a (color) # custom values for primitive are in the middle # labels x, y, text, size, alignment, r, g, b, a # sprites x, y, w, h, path, angle, alpha # lines x, y, x1, y1, r, g, b, a # solids x, y, w, h, r, g, b, a # borders x, y, w, h, r, g, b, a # sounds ".wav|.ogg" def defaults game_state game_state.game.ship_x ||= game_state.grid.w_half - 33 end def render game_state game_state.outputs.labels << [ game_state.grid.w_half, game_state.grid.h - 10, "Galaga", 1, 1, 0, 0, 255, 255] game_state.outputs.sprites << [ game_state.game.ship_x, 10, 66, 66, "ship_blue.png", 90] if game_state.game.bullet_x game_state.outputs.sprites << [ game_state.game.bullet_x, game_state.game.bullet_y, 10, 10, "blue_bullet.png"] end end def calc game_state if game_state.game.bullet_x game_state.game.bullet_y += 8 if game_state.game.bullet_y > game_state.grid.h game_state.game.bullet_x = game_state.game.bullet_y = nil end end game_state.game.ship_x -= game_state.grid.w if game_state.game.ship_x >= game_state.grid.w game_state.game.ship_x += game_state.grid.w if game_state.game.ship_x <= 0 end def inputs game_state if game_state.inputs.controller_one.key_held.right game_state.game.ship_x += 10 elsif game_state.inputs.controller_one.key_held.left game_state.game.ship_x -= 10 end if ( game_state.inputs.controller_one.key_down.a || game_state.inputs.controller_one.key_down.b ) && !game_state.game.bullet_x game_state.game.bullet_x = game_state.game.ship_x + 28 game_state.game.bullet_y = 76 end end def tick game_state defaults game_state render game_state calc game_state inputs game_state end