Guest User

Untitled

a guest
Nov 18th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. require 'chingu'
  2.  
  3.  
  4.  
  5. class Player < Chingu::GameObject
  6. def initialize
  7. super
  8. self.x, self.y = 200, 200
  9. self.image = Gosu::Image["ship1.jpg"]
  10. self.input = {
  11. :holding_left => :move_left,
  12. :holding_right => :move_right,
  13. :holding_up => :move_up,
  14. :holding_down => :move_down }
  15. end
  16.  
  17. def move_left; @x -= 3; end
  18. def move_right; @x += 3; end
  19. def move_up; @y -= 3; end
  20. def move_down; @y += 3; end
  21. end
  22.  
  23. class Game < Chingu::Window
  24. def initialize
  25. super(600,600,false)
  26. self.input = { :y => :exit }
  27. @player = Player.create
  28. end
  29. def update
  30. super
  31. self.caption = "FPS: #{self.fps}"
  32. end
  33. end
  34.  
  35. @game = Game.new
  36. @game.show
Add Comment
Please, Sign In to add comment