Advertisement
_ptitloupbey

BeyCube Application

Jun 24th, 2020
929
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2.     (import "sfml.arkm")
  3.     (import "Switch.ark")
  4.     #(import "Functional/Exceptions.ark")
  5.  
  6.     (let screen (sfWindowInit 1300 600 "BeyCube Game"))
  7.     (sfWindowSetFPS 60)
  8.  
  9.     (let font (sfLoadFont "fonts/police.ttf"))
  10.  
  11.  
  12.  
  13.     #Variable
  14.     (mut compteur 0)
  15.  
  16.     (mut score 0)
  17.  
  18.     (mut speed 6)
  19.  
  20.     (mut up false)
  21.     (mut left false)
  22.     (mut down false)
  23.     (mut right false)
  24.  
  25.     (mut x 50)
  26.     (mut y 50)
  27.  
  28.     #Textes
  29.     (let charg (sfMakeText font "Chargement." 50 [255 255 255]))
  30.     (sfSetPos charg (/ (- 1300 (sfWidth charg)) 2) (/ (- 600 (sfHeight charg)) 2))
  31.  
  32.     (let tab (sfMakeText font "Score: Non" 28 [255 255 255]))
  33.     (sfSetPos tab (/ (- 1080 (sfWidth tab)) 2) 120)
  34.     (sfSetText tab (+ "Score: " (toString score)))
  35.  
  36.  
  37.     #Image
  38.     (let starttime (time))
  39.     (let background (sfLoadSprite "img/background.png"))
  40.     (let perso (sfLoadSprite "img/perso.png"))
  41.  
  42.     (let sprite (fun () {
  43.         (let move (fun (direction posX posY) {
  44.             (switch direction [
  45.                ["up" '{(sfSetPos perso posX posY) (set y (- y speed))}]
  46.                ["down" '{(sfSetPos perso posX posY) (set y (+ y speed))}]
  47.                ["right" '{(sfSetPos perso posX posY) (set x (+ x speed))}]
  48.                ["left" '{(sfSetPos perso posX posY) (set x (- x speed))}]
  49.             ])                
  50.         }))
  51.  
  52.         (fun (&move) ())
  53.     }))
  54.  
  55.     (let object (sprite))
  56.  
  57.     (while (sfWindowIsOpen) {
  58.         (mut event (sfPollEvent))
  59.         (switch event [
  60.             [(sfEvent "quit") '(sfWindowClose)]
  61.  
  62.             [(sfEvent "keydown" "right") '(set right true)]
  63.             [(sfEvent "keydown" "left") '(set left true)]
  64.             [(sfEvent "keydown" "up") '(set up true)]
  65.             [(sfEvent "keydown" "down") '(set down true)]
  66.  
  67.             [(sfEvent "keyup" "right") '(set right false)]
  68.             [(sfEvent "keyup" "left") '(set left false)]
  69.             [(sfEvent "keyup" "up") '(set up false)]
  70.             [(sfEvent "keyup" "down") '(set down false)]
  71.  
  72.         ])
  73.  
  74.         (mut diff (- (time) starttime))
  75.  
  76.         (sfWindowClear 0 0 0)
  77.         (if (< diff (* 3 3))
  78.         {
  79.           (switch (mod (floor diff) 3) [
  80.              [0 '(sfSetText charg "Chargement.")]
  81.              [1 '(sfSetText charg "Chargement..")]
  82.              [2 '{(sfSetText charg "Chargement...")}]
  83.           ])
  84.           (sfDraw charg)
  85.  
  86.         }
  87.         {
  88.             (sfDraw background)
  89.             (sfDraw perso)
  90.             (sfDraw tab)
  91.         }
  92.         )
  93.  
  94.         (if right (object.move "right" (+ x speed) y) ())
  95.         (if left (object.move "left" (- x speed) y) ())
  96.         (if up (object.move "up" x (- y speed)) ())
  97.         (if down (object.move "down" x (+ y speed)) ())
  98.  
  99.         (sfWindowDisplay)
  100.     })
  101. }
Advertisement
RAW Paste Data Copied
Advertisement