Weekly Qbasic and Qb64 Lesson Topics
April 25, 2018, 05:24:18 am
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

Arcade


Pages: [1]
  Print  
Author Topic: Arcade  (Read 373 times)
Dustie Bear
Full Member
***
Posts: 115


« on: March 12, 2011, 08:19:33 am »


Hi

 A bit of nostalgia from the atari 2600 days.
I dont remember the name that atari had for a game similar to this so
I just called Arcade!

I Wrote this many years ago in Quick basic but recently updated it  to use
some QB64 commands to make it run more smoothly and not flicker
on the screen.

It has a few sounds resembling the old atari sounds. at least close! LOL

Code:
 
'   arcade 
'-----------

SCREEN 9

'_FULLSCREEN

CONST KEY_KP_LEFT& = 200004
CONST KEY_KP_RIGHT& = 200006
mus1$ = "MbO2L64cgdgbgag"
mus2$ = "MbO3L64cgdgbgag"
mus3$ = "MbO4L64cgdgbgag"
mus4$ = "MbO5L64cgdgbgag"
music$ = "mbO3L32P64afgcO2eaL64eccO4fgbb"
mus5$ = "mbO3L32P64CDEFGCACDCECFCGO4CDECACDCFCDFDA"
DEFINT A-Z
ccc = 1
'==================== setup for new game ========================
newgame:
Shooter = 1 'How fast shooter moves vack and forth
Shot = 2 'speed of bullet
dis = 1 'speed that targets move
ball = 12 'number of bullets
score = 0
fall = 5 'targets go up and down
r = 65 'size of targets, changes during the game

'======================== setup for next level ===================
start:

r = r - 12 'size of targets
IF r < 12 THEN
   r = 65
   dis = dis + 1
   ccc = ccc + 1
   IF dis > 4 THEN dis = 2
END IF
LINE (0, 0)-(640, 350), ccc, BF
LINE (1, 335)-(640, 350), 0, BF
LOCATE 25, 55
PRINT "SCORE  "; score;

e = 300 ' position shooter
w = 300
d = 270
'-----------------------
u = 50 ' position targets
uu = 100
i = 190
ii = 280
m = 370
mm = 460
x = 550
xx = 640
s = 0 ' reset counter -8 targets to shoot
'----------------------
h = 8 'color of targets
j = 9
k = 10
gg = 11
hh = 12
jj = 14
kk = 13

FOR turns = 1 TO ball 'play till run out of balls
   CIRCLE (turns * 15, 340), 4, 15
   PAINT (turns * 15, 340), 7, 15
NEXT turns

LINE (e, 310)-(e + 4, 320), 0, BF
'==============================================================
WHILE a$ <> "q"
   _LIMIT 120


   a$ = INKEY$ 'need this if quit, Also asks at end of game if you want to quit Y/N
   IF a$ = LCASE$("q") THEN SYSTEM

   '----- Use Left and Right arrow keys to move the shooter
   IF _KEYDOWN(CVI(CHR$(0) + "M")) THEN
      LINE (e, 310)-(e + 4, 320), ccc, BF
      e = e + Shooter
      LINE (e, 310)-(e + 4, 320), 0, BF
   END IF
   IF _KEYDOWN(CVI(CHR$(0) + "K")) THEN
      LINE (e, 310)-(e + 4, 320), ccc, BF
      e = e - Shooter
      LINE (e, 310)-(e + 4, 320), 0, BF
   END IF

   '--------------------------------------------
   IF b = 0 THEN
      FOR t = 1 TO 100
      NEXT t
   END IF

   '  erase targets
   LINE (x, fall)-(x + dis, fall + 7), ccc, BF
   LINE (i, fall)-(i + dis, fall + 7), ccc, BF
   LINE (m, fall)-(m + dis, fall + 7), ccc, BF
   LINE (uu, fall)-(uu + dis, fall + 7), ccc, BF
   LINE (xx, fall)-(xx + dis, fall + 7), ccc, BF
   LINE (ii, fall)-(ii + dis, fall + 7), ccc, BF
   LINE (mm, fall)-(mm + dis, fall + 7), ccc, BF

   'rotate targets to beginning of screen
   IF x > 640 THEN x = 0
   IF u > 640 THEN u = 0
   IF i > 640 THEN i = 0
   IF m > 640 THEN m = 0
   IF xx > 640 THEN xx = 0
   IF uu > 640 THEN uu = 0
   IF ii > 640 THEN ii = 0
   IF mm > 640 THEN mm = 0

   ' ---- targets move down or up  randonly at random times
   rd = INT(RND * 500)
   IF rd = 25 THEN
      LINE (0, 0)-(640, 300), ccc, BF
      fall = INT(RND * 250)
   END IF

   x = x + dis
   u = u + dis
   m = m + dis
   i = i + dis
   xx = xx + dis
   uu = uu + dis
   mm = mm + dis
   ii = ii + dis
   '  draw targets going across the screen
   LINE (x, fall)-(x + r, fall + 7), h, BF
   LINE (i, fall)-(i + r, fall + 7), j, BF
   LINE (m, fall)-(m + r, fall + 7), k, BF
   LINE (uu, fall)-(uu + r, fall + 7), gg, BF
   LINE (xx, fall)-(xx + r, fall + 7), hh, BF
   LINE (ii, fall)-(ii + r, fall + 7), jj, BF
   LINE (mm, fall)-(mm + r, fall + 7), kk, BF

   'Level up - fanfare to start next round
   IF s = 7 THEN
      b = 0
      ball = ball + 12
      IF ball > 12 THEN ball = 12
      LINE (e, 310)-(e + 4, 320), ccc, BF
      PLAY music$
      PLAY mus2$
      PLAY mus$
      PLAY mus3$
      GOTO start
   END IF
   IF POINT(w + 3, d) <> ccc THEN
      IF POINT(w + 3, d) = h THEN h = ccc: s = s + 1: PLAY mus2$: score = score + 50
      IF POINT(w + 3, d) = j THEN j = ccc: s = s + 1: PLAY mus3$: score = score + 50
      IF POINT(w + 3, d) = k THEN k = ccc: s = s + 1: PLAY mus4$: score = score + 50
      IF POINT(w + 3, d) = gg THEN gg = ccc: s = s + 1: PLAY mus1$: score = score + 50
      IF POINT(w + 3, d) = hh THEN hh = ccc: s = s + 1: PLAY mus2$: score = score + 50
      IF POINT(w + 3, d) = jj THEN jj = ccc: s = s + 1: PLAY mus3$: score = score + 50
      IF POINT(w + 3, d) = kk THEN kk = ccc: s = s + 1: PLAY mus4$: score = score + 50
   END IF
   IF POINT(w - 3, d) <> ccc THEN
      IF POINT(w - 3, d) = h THEN h = ccc: s = s + 1: PLAY mus2$: score = score + 50
      IF POINT(w - 3, d) = j THEN j = ccc: s = s + 1: PLAY mus3$: score = score + 50
      IF POINT(w - 3, d) = k THEN k = ccc: s = s + 1: PLAY mus4$: score = score + 50
      IF POINT(w - 3, d) = gg THEN gg = ccc: s = s + 1: PLAY mus1$: score = score + 50
      IF POINT(w - 3, d) = hh THEN hh = ccc: s = s + 1: PLAY mus2$: score = score + 50
      IF POINT(w - 3, d) = jj THEN jj = ccc: s = s + 1: PLAY mus3$: score = score + 50
      IF POINT(w - 3, d) = kk THEN kk = ccc: s = s + 1: PLAY mus4$: score = score + 50
   END IF

   '-------------------------------------------
   IF a$ = " " THEN b = 1: w = e
   a$ = ""

   IF _KEYDOWN(CVI(CHR$(0) + "M")) THEN
      LINE (e, 310)-(e + 4, 320), ccc, BF
      e = e + Shot
      IF e > 630 THEN e = 630
      LINE (e, 310)-(e + 4, 320), 0, BF
   END IF

   IF _KEYDOWN(CVI(CHR$(0) + "K")) THEN
      LINE (e, 310)-(e + 4, 320), ccc, BF
      e = e - Shot
      IF e < 10 THEN e = 5
      LINE (e, 310)-(e + 4, 320), 0, BF
   END IF

   IF b = 1 THEN
      PAINT (w, d), ccc, ccc
      CIRCLE (w, d), 4, ccc
      d = d - Shot
      CIRCLE (w, d), 4, 15
      PAINT (w, d), 15, 15
      IF d < fall + 1 THEN
         LOCATE 25, 62
         PRINT score;
         b = 0
         PAINT (w, d), ccc, ccc
         CIRCLE (w, d), 4, ccc
         d = 270
         w = 300
         ball = ball - 1
         IF ball < 0 THEN GOTO choice
         LINE (1, 335)-(400, 600), 0, BF
         FOR turns = 1 TO ball
            CIRCLE (turns * 15, 340), 4, 15
            PAINT (turns * 15, 340), 7, 15
         NEXT turns
      END IF
   END IF
   _DISPLAY
WEND

choice:
_AUTODISPLAY
LOCATE 25, 25
PRINT "Play again ?  Y)es or N)o";
PLAY "p64l64o4cbagfeo3cbagfeo2cbagfeo1cbagfe"
c1:
a$ = INKEY$
IF LCASE$(a$) = "y" THEN: ccc = 1: GOTO newgame
IF LCASE$(a$) = "n" THEN SYSTEM
GOTO c1
Report Spam   Logged

Social Buttons

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #1 on: March 12, 2011, 08:53:29 pm »

I like they way you use mus1$="MBabcdefg"   
and then just,   
        PLAY music$
        PLAY mus2$
        PLAY mus$
        PLAY mus3$
I have never seen it done this way,...but they way the game runs and sounds, looks like a good way to do it.
from Garry
Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #2 on: March 13, 2011, 12:23:52 am »



Quote
I like they way you use mus1$="MBabcdefg"
    This is a good way to have lots different tunes available. Imagine you created all the tunes and saved them as data statements. Then at program start you create a string dim and load them . Then you call them when needed by the index number.


 Would this also work in a game like the pacman game we are working on ?....Guess I can try, too..
from Garry
« Last Edit: September 13, 2011, 07:00:01 pm by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #3 on: March 13, 2011, 01:37:32 am »

Ok, mostly just wondered if it would work,
Quote
The sounds would be much better in the new format.
So that is what it sounds like ,you are saying, it could work, but the new format is better,...I agree, as PLAY, SOUND,
seems to slow things down or interrupt the flow,...or even stop the program.
 I guess some of that depends on what sort of game too, as in his arcade it seems to work well...Also the midi can be more like music, or even a voice,..if one wants. from Garry
Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #4 on: September 13, 2011, 07:09:17 pm »

 I removed a "example" some one posted, the code did not work,..

- Dustys original code works fine, it is a pretty neat game.
from Garry
« Last Edit: September 13, 2011, 07:12:41 pm by GarrisonRicketson » Report Spam   Logged


Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Buy traffic for your forum/website
traffic-masters
Powered by SMF | SMF © 2016, Simple Machines