Author Topic: Japang!  (Read 3886 times)

0 Members and 1 Guest are viewing this topic.

Offline Prithak

  • Newbie
  • Posts: 56
  • Life itself is a Programming Language!
    • View Profile
    • My Programming Language
Japang!
« on: April 13, 2019, 08:23:40 am »
Sorry for the weird name! I'll change it soon enough!

This is a game I made in 2 days:
Code: QB64: [Select]
  1. 'First Prototype of my game project!
  2. 'Never knew I would get this far!
  3. 'A Special thanks to Petr, Pete, bplus, _vince, TempodiBasic, SMcNeil Let me know if I forgot your name here xD
  4. '-Prithak
  5.  
  6. _TITLE "Japang!"
  7. SCREEN _NEWIMAGE(800, 600, 32)
  8. COLOR _RGB32(0, 0, 0), _RGB32(211, 211, 211)
  9. DIM SHARED y_change AS SINGLE
  10.     _PRINTSTRING (600, 100), "Japang!"
  11.     _PRINTSTRING (600, 300), "Play"
  12.     _PRINTSTRING (600, 400), "Exit"
  13.     LINE (570, 290)-(600 + LEN("play") * 16, 325), _RGB32(255, 255, 255), B
  14.     LINE (570, 390)-(600 + LEN("exit") * 16, 425), _RGB32(255, 255, 255), B
  15.     IF mouseclick(570, 290, 600 + LEN("play") * 16, 325) THEN
  16.         game
  17.     END IF
  18.     IF mouseclick(570, 290, 600 + LEN("play") * 16, 425) THEN
  19.         SYSTEM
  20.     END IF
  21.  
  22.  
  23. SUB game
  24.     x = 200
  25.     y = 200
  26.     gravity = 9.8
  27.     CLS
  28.     DO
  29.         CLS
  30.         makechar
  31.         IF _KEYDOWN(19200) THEN
  32.             x = x - 10
  33.  
  34.         END IF
  35.         IF _KEYDOWN(19712) THEN
  36.             x = x + 10
  37.  
  38.         END IF
  39.         IF _KEYDOWN(18432) THEN
  40.             jump_i = 1
  41.         END IF
  42.  
  43.         IF jump_i = 1 AND y > 100 THEN
  44.             y = y - 20
  45.             cycle = cycle + 1
  46.             IF cycle > 20 THEN cycle = 0: jump_i = -1
  47.         END IF
  48.  
  49.         y = y + gravity
  50.         'Blocks
  51.         makeobs 100, 400
  52.  
  53.         LINE (500, 400)-STEP(200, 50), _RGB32(127, 255, 127), BF
  54.         IF collision%(x, y, 20, 20, 500, 400, 200, 50) THEN
  55.             CLS
  56.             _PRINTSTRING (300, 300), "LEVEL 1 COMPLETE!"
  57.             _DISPLAY
  58.             _DELAY 2
  59.             GOTO lvl2
  60.             END
  61.         END IF
  62.         IF y > 600 THEN game
  63.  
  64.         _DISPLAY
  65.         _LIMIT 60
  66.     LOOP
  67.  
  68.     lvl2:
  69.     x = 200
  70.     y = 400
  71.     DO
  72.         CLS
  73.         makechar
  74.         IF _KEYDOWN(19200) THEN
  75.             x = x - 10
  76.  
  77.         END IF
  78.         IF _KEYDOWN(19712) THEN
  79.             x = x + 10
  80.  
  81.         END IF
  82.         IF _KEYDOWN(18432) THEN
  83.             jump_i = 1
  84.         END IF
  85.  
  86.         IF jump_i = 1 AND y > 100 THEN
  87.             y = y - 20
  88.             cycle = cycle + 1
  89.             IF cycle > 20 THEN cycle = 0: jump_i = -1
  90.         END IF
  91.  
  92.         y = y + gravity
  93.  
  94.         IF y > 600 THEN GOTO lvl2
  95.         angle = angle + 5
  96.  
  97.         rotate _WIDTH / 2, _HEIGHT / 2, angle
  98.  
  99.  
  100.         makeobs 100, 500
  101.  
  102.         makeobs 500, 500
  103.  
  104.         IF coins < 1 THEN
  105.             CIRCLE (600, 480), 5, _RGB32(255, 255, 17)
  106.             PAINT (600, 480), _RGB32(255, 255, 17), _RGB32(255, 255, 17)
  107.             IF collision%(x, y, 20, 20, 600, 480, 5, 5) THEN
  108.                 coins = coins + 1
  109.             END IF
  110.         END IF
  111.  
  112.         LINE (100, 300)-STEP(200, 50), _RGB32(127, 255, 127), BF
  113.         IF collision%(x, y, 20, 20, 100, 300, 200, 50) THEN
  114.             CLS
  115.             _PRINTSTRING (300, 300), "LEVEL 2 COMPLETE!"
  116.             _PRINTSTRING (300, 325), "Coins collected: " + STR$(coins)
  117.             _DISPLAY
  118.             _DELAY 2
  119.             GOTO lvl3
  120.             END
  121.         END IF
  122.  
  123.         _DISPLAY
  124.         _LIMIT 60
  125.     LOOP
  126.  
  127.     lvl3:
  128.     x = 100
  129.     y = 300
  130.     DO
  131.         CLS
  132.         makechar
  133.  
  134.         IF _KEYDOWN(19200) THEN
  135.             x = x - 10
  136.  
  137.         END IF
  138.         IF _KEYDOWN(19712) THEN
  139.             x = x + 10
  140.  
  141.         END IF
  142.         IF _KEYDOWN(18432) THEN
  143.             jump_i = 1
  144.         END IF
  145.  
  146.         IF jump_i = 1 AND y > 100 THEN
  147.             y = y - 20
  148.             cycle = cycle + 1
  149.             IF cycle > 20 THEN cycle = 0: jump_i = -1
  150.         END IF
  151.  
  152.         y = y + gravity
  153.  
  154.         IF coins < 2 THEN
  155.             CIRCLE (650, 470), 5, _RGB32(255, 255, 17)
  156.             PAINT (650, 470), _RGB32(255, 255, 17), _RGB32(255, 255, 17)
  157.             IF collision%(x, y, 20, 20, 650, 470, 5, 5) THEN
  158.                 coins = coins + 1
  159.             END IF
  160.         END IF
  161.  
  162.  
  163.         makesobs 50, 500, 100, 50
  164.  
  165.         angle = angle + 5
  166.  
  167.         rotate _WIDTH / 2, 400, angle
  168.         rotate _WIDTH / 2, 200, angle
  169.  
  170.         makesobs 600, 500, 100, 50
  171.  
  172.         LINE (100, 200)-STEP(200, 50), _RGB32(127, 255, 127), BF
  173.         IF collision%(x, y, 20, 20, 100, 50, 200, 50) THEN
  174.             CLS
  175.             _PRINTSTRING (300, 300), "LEVEL 3 COMPLETE!"
  176.             _PRINTSTRING (300, 325), "Total coins: " + STR$(coins)
  177.             _DISPLAY
  178.             _DELAY 2
  179.             END
  180.         END IF
  181.  
  182.         IF y > 600 THEN GOTO lvl3
  183.  
  184.         _DISPLAY
  185.         _LIMIT 60
  186.     LOOP
  187.  
  188. SUB makechar
  189.     'CIRCLE (x, y), 20, _RGB32(100, 150, 255)
  190.     'PAINT (x, y), _RGB32(100, 150, 255), _RGB32(100, 150, 255)
  191.     LINE (x, y)-STEP(20, 20), _RGB32(100, 150, 255), BF
  192.  
  193. FUNCTION collision% (b1x, b1y, b1w, b1h, b2x, b2y, b2w, b2h)
  194.     IF (b1y + b1h < b2y) OR (b1y > b2y + b2h) OR (b1x > b2x + b2w) OR (b1x + b1w < b2x) THEN
  195.         collision% = 0
  196.     ELSE
  197.         collision% = 1
  198.     END IF
  199.  
  200. SUB makeobs (bx, by)
  201.     LINE (bx, by)-STEP(200, 50), _RGB32(255, 150, 100), BF
  202.     IF collision%(x, y, 20, 20, bx, by, 200, 50) THEN
  203.         y = oldy
  204.         gravity = 0
  205.         y_change = 0
  206.     ELSE
  207.         oldy = y
  208.         gravity = 9.8
  209.     END IF
  210.  
  211. SUB makesobs (bx, by, w, h)
  212.     LINE (bx, by)-STEP(w, h), _RGB32(255, 150, 100), BF
  213.     IF collision%(x, y, 20, 20, bx, by, w, h) THEN
  214.         y = oldy
  215.         gravity = 0
  216.         y_change = 0
  217.     ELSE
  218.         oldy = y
  219.         gravity = 9.8
  220.     END IF
  221.  
  222. SUB rotate (px, py, deg)
  223.     px2 = px + COS(_D2R(deg)) * 100
  224.     py2 = py + SIN(_D2R(deg)) * 100
  225.  
  226.     CIRCLE (px2, py2), 10, _RGB32(100, 150, 255)
  227.     PAINT (px2, py2), _RGB32(100, 150, 255), _RGB32(100, 150, 255)
  228.  
  229.     LINE (px, py)-(px2, py2), _RGB32(0, 0, 0)
  230.  
  231.     IF collision(x, y, 20, 20, px2, py2, 10, 10) THEN
  232.         CLS
  233.         _PRINTSTRING (300, 300), "GAME OVER!"
  234.         _DISPLAY
  235.         _DELAY 2
  236.         game
  237.     END IF
  238.  
  239. FUNCTION mouseclick (x1, y1, x2, y2)
  240.     mx = _MOUSEX
  241.     my = _MOUSEY
  242.     mb = _MOUSEBUTTON(1)
  243.  
  244.     IF mx >= x1 AND mx <= x2 AND my >= y1 AND my <= y2 AND mb THEN
  245.         mouseclick = 1
  246.     END IF
  247.  

I will be making more of this! AT LEAST 10 LEVELS! Until then, play this!

-Prithak
CLS
IF computer$ = "ON" THEN
me$ = "Happy!"
ELSE
me$ = "Time To Draw!"
END IF
END

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Japang!
« Reply #1 on: April 13, 2019, 05:14:49 pm »
Fine! Well suited. Very fast!

Please add <Help> button with instructions for keys active and a little story or the goal.

Negative Feedback:
Aargh! There is a big big big mistake at line code 25...
Code: QB64: [Select]
  1. IF mouseclick(570, 290, 600 + LEN("play") * 16, 425) THEN
you use LEN("play")! Aargh! you must use LEN("quit")!!!!
:-)
:-P what do you think of this joke?
Programming isn't difficult, only it's  consuming time and coffee

Offline Prithak

  • Newbie
  • Posts: 56
  • Life itself is a Programming Language!
    • View Profile
    • My Programming Language
Re: Japang!
« Reply #2 on: April 13, 2019, 09:19:32 pm »
Fine! Well suited. Very fast!

Please add <Help> button with instructions for keys active and a little story or the goal.

Negative Feedback:
Aargh! There is a big big big mistake at line code 25...
Code: QB64: [Select]
  1. IF mouseclick(570, 290, 600 + LEN("play") * 16, 425) THEN
you use LEN("play")! Aargh! you must use LEN("quit")!!!!
:-)
:-P what do you think of this joke?

Lol! The length of "play" and the length of "quit" is the same is it not? Yeah, The help button will be added along with setting on the next update! I won't be able to code today but tomorrow? That might be a nice time!
CLS
IF computer$ = "ON" THEN
me$ = "Happy!"
ELSE
me$ = "Time To Draw!"
END IF
END

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Japang!
« Reply #3 on: April 14, 2019, 01:02:00 pm »
Ah!
you're right!:
 
PLAY
QUIT<---  not this, I must wash better my glasses :-)
EXIT
HELP
SAVE
LOAD
PRINT
FIND
KILL
OPEN
NAME
STOP
BACK
...
...
mmmh all in 4 :-)
 doesn't it seem a trick of old times, does it?
it seems to catch back from '80 the names of command of menu of a program...
« Last Edit: April 14, 2019, 01:40:54 pm by TempodiBasic »
Programming isn't difficult, only it's  consuming time and coffee

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Japang!
« Reply #4 on: April 14, 2019, 01:13:34 pm »
Ah!
you're right!:
 
PLAY
QUIT
EXIT
HELP
SAVE
LOAD
PRINT
FIND
KILL
OPEN
NAME
STOP
BACK
...
...
mmmh all in 4 :-)
 doesn't it seem a trick of old times, does it?
it seems to catch back from '80 the names of command of menu of a program...

Sorry.  PRNT is 5 letters.  😉
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Japang!
« Reply #5 on: April 14, 2019, 01:39:11 pm »
You're right Steve
Thanks for feedback!

Now I correct previous post.
Programming isn't difficult, only it's  consuming time and coffee