Advertisement
Guest User

Untitled

a guest
Aug 24th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. var h1e = h1edpi_module
  3.  
  4. var FPS = 30
  5. var TICK_LENGTH = 1000/FPS
  6. var SCREEN_W = 240
  7. var SCREEN_H = 160
  8.  
  9. h1e.bgstyle = "#000000"
  10. h1e.init($("#main_canvas")[0], SCREEN_W, SCREEN_H, FPS)
  11.  
  12. //h1e.add_image("game", "game.png")
  13. //h1e.def_sprite("ship", "game"+m, [[0,0,16,16]])
  14.  
  15. function Game(){
  16.     this.tick = function(h1e){
  17.     }
  18. }
  19.  
  20. function GameSection(game){
  21.     game = game ? game : new Game()
  22.  
  23.     this.draw = function(h1e){
  24.     }
  25.     this.trigger_end = function(won){
  26.     }
  27.     this.event = function(h1e, event){
  28.         if(event.type == "keydown"){
  29.             if(h1e.iskey(event.key, ["escape", "q"])){
  30.                 //h1e.remove_section(this)
  31.                 return true
  32.             }
  33.         }
  34.     }
  35.     this.update = function(h1e){
  36.         if(h1e.keydown("left"))
  37.             console.log("left")
  38.         if(h1e.keydown("right"))
  39.             console.log("right")
  40.  
  41.         game.tick()
  42.  
  43.         return true
  44.     }
  45. }
  46.  
  47. h1e.push_section(new GameSection())
  48.  
  49. function pad_stuff(){
  50.     h1e.resize_canvas($(window).width() - 5, $(window).height() - 5)
  51. }
  52.  
  53. $(document).ready(function(){
  54.     pad_stuff()
  55.     $(window).resize(function(){
  56.         pad_stuff()
  57.     })
  58.     h1e.start()
  59. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement