Author Topic: advaced battle robot  (Read 3431 times)

0 Members and 1 Guest are viewing this topic.

Offline Primal

  • Newbie
  • Posts: 2
    • View Profile
advaced battle robot
« on: April 02, 2021, 08:11:05 am »
Hello everyone

I started several months ago a personal challage to create a very simple game and then recreate it slightly differently in other programming languages, using only assets created with the programming language itself, no extenal graphic files, no sound files (only exception are fonts).
I also used the original quick basic to create a dos binary just for fun.

Working with qb64 was fun and probaly the easiest programig language to work with.

I first started with Javascript/html, then C with SDL, then python with pygame and now QB64.
My itch.io page https://fildubek.itch.io/abr
Google drive with binaries https://cutt.ly/bzR3wmS
My git link https://github.com/fildubek/abr
Abrqb.png
* Abrqb.png (Filesize: 35.92 KB, Dimensions: 1931x1079, Views: 296)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: advaced battle robot
« Reply #1 on: April 02, 2021, 01:20:44 pm »
Welcome Primal,

Screen 2, ;-)) how old is this?
Code: QB64: [Select]
  1. lives = 3
  2. robot = 0
  3. missile = 0
  4. REM Loop through the story message until enter is pressed
  5.     CLS
  6.     PRINT "We managed to build our own robot, so now we can fight back"
  7.     PRINT " "
  8.     PRINT "Press ENTER to continue"
  9.     SLEEP 1
  10.     REM DRAW EVERYTHING IN LOOP
  11.     CLS
  12.     BEEP
  13.     REM DRAW GAME SCREEN
  14.     LINE (0, 0)-(610, 180), , B
  15.     LINE (530, 0)-(530, 180)
  16.     LINE (530, 70)-(610, 70), , B
  17.     REM WRITE INFO TEXT
  18.     LOCATE 3, 45
  19.     PRINT "AREA LEADER"
  20.     REM CALL ROBOT HEAD
  21.     robotHead
  22.     REM CALL LIVEBRARS
  23.     liveBars (lives)
  24.     REM CALL GRID
  25.     grid
  26.     REM CALL EVIL ROBOT BOSS
  27.     robotBoss (robot)
  28.     REM CALL MISSILE OPTIONS
  29.     missile = missileOptions
  30.     IF robot = 0 THEN
  31.         IF missile = 5 THEN
  32.             robot = success(robot)
  33.         ELSE
  34.             lives = failure(lives)
  35.         END IF
  36.  
  37.     ELSEIF robot = 1 THEN
  38.         IF missile = 2 THEN
  39.             robot = success(robot)
  40.         ELSE
  41.             lives = failure(lives)
  42.         END IF
  43.     ELSE
  44.         IF missile = 6 THEN
  45.             robot = success(robot)
  46.         ELSE
  47.             lives = failure(lives)
  48.         END IF
  49.     END IF
  50.  
  51.     SLEEP 5
  52.  
  53.  
  54.  
  55. FUNCTION missileOptions
  56.     LOCATE 20, 4
  57.     PRINT "1. MISSILE RED | 2. MISSILE BLACK | 3. MISSILE SILVER"
  58.     LOCATE 21, 4
  59.     PRINT "4. MISSILE GREEN | 5. MISSILE BLUE | 6. MISSILE YELLOW"
  60.     LOCATE 22, 4
  61.     INPUT "Enter a Missile: ", missile
  62.     missileOptions = missile
  63.  
  64.  
  65. SUB robotHead
  66.  
  67.     LINE (550, 30)-(590, 30)
  68.     LINE (550, 30)-(570, 15)
  69.     LINE (590, 30)-(570, 15)
  70.     LINE (565, 30)-(565, 38)
  71.     REM EYES AND NOSE
  72.     LINE (575, 30)-(575, 38)
  73.     LINE (565, 38)-(575, 38)
  74.     LINE (570, 30)-(570, 38)
  75.     LINE (558, 30)-(558, 33)
  76.     LINE (558, 33)-(565, 33)
  77.     LINE (582, 30)-(582, 33)
  78.     LINE (582, 33)-(575, 33)
  79.     REM FACE LINES
  80.     LINE (565, 38)-(555, 42)
  81.     LINE (575, 38)-(585, 42)
  82.  
  83.     LINE (555, 42)-(555, 47)
  84.     LINE (585, 42)-(585, 47)
  85.     REM MOUTH
  86.     LINE (565, 43)-(575, 43)
  87.     LINE (565, 45)-(575, 45)
  88.     LINE (565, 43)-(565, 45)
  89.     LINE (575, 43)-(575, 45)
  90.     REM FACE LINES
  91.     LINE (555, 47)-(585, 47)
  92.     LINE (555, 47)-(550, 47)
  93.     LINE (575, 47)-(590, 47)
  94.     LINE (550, 47)-(555, 42)
  95.     LINE (590, 47)-(585, 42)
  96.     LINE (550, 47)-(550, 30)
  97.     LINE (590, 47)-(590, 30)
  98.     LINE (552, 30)-(555, 42)
  99.     LINE (588, 30)-(585, 42)
  100.     REM HORNS
  101.     LINE (550, 40)-(537, 24)
  102.     LINE (537, 24)-(537, 15)
  103.     LINE (537, 15)-(546, 20)
  104.     LINE (546, 20)-(546, 24)
  105.     LINE (546, 24)-(550, 30)
  106.  
  107.     LINE (590, 40)-(603, 24)
  108.     LINE (603, 24)-(603, 15)
  109.     LINE (603, 15)-(594, 20)
  110.     LINE (594, 20)-(594, 24)
  111.     LINE (594, 24)-(590, 30)
  112.  
  113. SUB liveBars (lives)
  114.     x = 0
  115.     FOR i = 0 TO lives - 1
  116.         LOCATE 12, 70
  117.         PRINT "LIVES"
  118.         LINE (545 + x, 110)-(555 + x, 150), , B
  119.         PAINT (546 + x, 111), 3, 3
  120.         x = x + 20
  121.     NEXT i
  122.  
  123. SUB grid
  124.     x = 0
  125.     x2 = 0
  126.     FOR i = 0 TO 10
  127.         LINE (10 + x, 150)-(30 + x - x2, 75)
  128.         LINE (490 - x, 150)-(470 - x + x2, 75)
  129.         x = x + 20
  130.         x2 = x2 + 1
  131.     NEXT i
  132.  
  133.     LINE (230, 150)-(230, 75)
  134.     LINE (250, 150)-(250, 75)
  135.     LINE (270, 150)-(270, 75)
  136.  
  137.     x = 0
  138.     y = 0
  139.     FOR j = 0 TO 4
  140.         LINE (10 + x, 150 - y)-(490 - x, 150 - y)
  141.         x = x + 5
  142.         y = y + 19
  143.  
  144.     NEXT j
  145.  
  146.  
  147. SUB robotBoss (robot)
  148.  
  149.     IF robot = 0 THEN
  150.         LOCATE 5, 4
  151.         PRINT "WEAKNESS DETECTED"
  152.         LOCATE 6, 4
  153.         PRINT "0, 0, 255"
  154.     END IF
  155.  
  156.     IF robot = 1 THEN
  157.         LOCATE 5, 4
  158.         PRINT "NEW WEAKNESS DETECTED"
  159.         LOCATE 6, 4
  160.         PRINT "#000000"
  161.     END IF
  162.     IF robot = 2 THEN
  163.         LOCATE 5, 4
  164.         PRINT "NEW WEAKNESS DETECTED"
  165.         LOCATE 6, 4
  166.         PRINT "0%, 0%, 100%, 0%"
  167.     END IF
  168.  
  169.  
  170.  
  171.     LINE (200, 10)-(240, 5)
  172.     LINE -(280, 10)
  173.     LINE -(280, 30)
  174.     LINE -(240, 25)
  175.     LINE -(200, 30)
  176.     LINE -(200, 10)
  177.     LINE (200, 30)-(200, 50)
  178.     LINE -(220, 55)
  179.     LINE -(220, 70)
  180.     LINE (280, 30)-(280, 50)
  181.     LINE -(260, 55)
  182.     LINE -(260, 70)
  183.     LINE (210, 35)-(225, 35)
  184.     LINE -(218, 40)
  185.     LINE -(210, 35)
  186.     LINE (270, 35)-(255, 35)
  187.     LINE -(262, 40)
  188.     LINE -(270, 35)
  189.     LINE (235, 30)-(235, 45)
  190.     LINE -(245, 45)
  191.     LINE -(245, 30)
  192.     REM FACE LINES
  193.     LINE (235, 45)-(230, 55)
  194.     LINE -(200, 40)
  195.     LINE (230, 55)-(230, 70)
  196.     LINE (245, 45)-(250, 55)
  197.     LINE -(280, 40)
  198.     LINE (250, 55)-(250, 70)
  199.     REM MOUTH
  200.     LINE (233, 62)-(247, 62)
  201.     LINE -(250, 65)
  202.     LINE (233, 62)-(230, 65)
  203.  
  204.  
  205. FUNCTION success (robot)
  206.     SOUND 70, 10
  207.     IF robot < 2 THEN
  208.         robot = robot + 1
  209.         LOCATE 5, 40
  210.         PRINT "DIRECT HIT!"
  211.     ELSE
  212.         LOCATE 5, 40
  213.         PRINT "DIRECT HIT! CONGRATULATIONS"
  214.         LOCATE 6, 40
  215.         PRINT "AREA LEADER DEFEATED,"
  216.         LOCATE 7, 40
  217.         PRINT "RECEIVING UPGRADES"
  218.         SLEEP 3000
  219.         SYSTEM
  220.     END IF
  221.     success = robot
  222.  
  223. FUNCTION failure (lives)
  224.     SOUND 300, 10
  225.     LOCATE 5, 40
  226.     PRINT "WRONG MISSILE,"
  227.     LOCATE 6, 40
  228.     PRINT "COUNTER HIT DAMAGE"
  229.     IF lives > 0 THEN
  230.         lives = lives - 1
  231.     ELSE
  232.         LOCATE 5, 40
  233.         PRINT "LOST ALL YOUR LIVES"
  234.         LOCATE 6, 40
  235.         PRINT "YOU HAVE BEEN DEFEATED,"
  236.         SLEEP 3000
  237.         SYSTEM
  238.     END IF
  239.     failure = lives
  240.  

Works but apparently I keep entering wrong missile. Some instructions might be helpful.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: advaced battle robot
« Reply #2 on: April 02, 2021, 02:27:51 pm »
Quote
REM Loop through the story message until enter is pressed
DO
    CLS
    PRINT "We managed to build our own robot, so now we can fight back"
    PRINT " "
    PRINT "Press ENTER to continue"
    SLEEP 1
LOOP UNTIL INKEY$ = CHR$(13)

Ah maybe there was something in story message that didn't get finished or was cut?

Offline Primal

  • Newbie
  • Posts: 2
    • View Profile
Re: advaced battle robot
« Reply #3 on: April 03, 2021, 06:51:07 am »
Like a said I wanted it to run also on Dos, that is why I use screen 2.

As for the message it is not cut, but each version of the game contains part of it.