News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

My First -very simple- Completed PlayBasic Game. Street Fight.

Started by Pagan Slim, June 16, 2010, 12:01:21 PM

Previous topic - Next topic

Pagan Slim

This is my first game made with PlayBASIC.com.  It's even a little fun the first time or two.  It was a great learning experience and took only a few days to go from nothing to something. :P

Even though this game works it is still poorly coded and is an example of inefficiency.  


PlayBASIC Code: [Select]
; PROJECT : Street Fight
; AUTHOR : Pagan Slim
; CREATED : 6/13/2010
; EDITED : 6/16/2010
; ---------------------------------------------------------------------
;This program simulates you being in a fight with a group
;of attackers. The number of attackers vary but actual
;combat is one on one with the opponent being presented
;by the program as a group by means of a 'for next' loop.
;Each attacker has their own name and are like individuals.
;I plan to put the fighters and their stats into an array
;and perhaps keep the data in an editable external file.
;That's a tall order for me at this time.


LoadFont "Arial",1,18,0

Setfps 30

CLS RGB(95,0,0)
Print "You are walking the streets of a well known but feared neighborhood."
Print "You usually avoid this part of town but today is different."
print "You feel braver today. Braver and perhaps a bit more foolish."
print "You made your boast to your friends and they dared you to come here."
print "You feel a chill. Maybe a shudder. You hear a garbage pail being knocked over."
print "The sound jolts you to a higher awareness of your reality. "

print " "
print "You see someone ahead of you. It is dark and foggy tonight."
print "Are you ready to throw down? Well. Are You?"
print " "
PRINT "Press the ENTER key to get it on."
print " "
SYNC
WAITKEY

;combat routine
CLS RGB(85,0,0)
;Initialize AND Randomize
;create stats

;Number of NPC's that you will fight.
NUM_GUYS = RND (5)+ 1


NPC_HITPOINTS = RNDRANGE (2,10)+2

HITPOINTS = RNDRANGE (20,35);ADJUSTED TO EQUAL THE ODDS.

PRINT "YOUR HIT POINTS " + Str$(HITPOINTS)
PRINT " "
PRINT "NPC GROUP HIT POINTS " + Str$(NPC_HITPOINTS)
PRINT " "
sync
WAIT 3000

;Game Loop
DO
;Initiative:
;who's first
COINTOSS=RND (120)

;PRINT "* INITIATIVE * " + Str$(COINTOSS)
;PRINT " "
;SYNC

PRINT "Number of NPCs " + Str$(NUM_GUYS)
print " "
SYNC

IF COINTOSS>60
PRINT "The initiative is yours."
PRINT " "
ELSE
PRINT "NPC(s) has initiative."
PRINT " "
ENDIF



IF COINTOSS>60
GOSUB MEFIRST:
ELSE
GOSUB NPCFIRST
ENDIF

PRINT "Press a key to go on."
PRINT " "
SYNC
WAITKEY
Cls RGB(85,0,0)

;CLS ;clear screen for next round of combat.
LOOP


;npcfirst
NPCFIRST:
;attack (is it successful)
;N is which of the npc's attack.
FOR N = 1 TO NUM_GUYS
IF N = 1
PRINT "Bucktooth Sam Attacks."
ENDIF
IF N = 2
PRINT "Bad Bob Attacks You."
sync
ENDIF
IF N = 3
PRINT "Wicked Wanda Attacks You."
ENDIF
IF N = 4
PRINT "Evil Earl Attacks You."

ENDIF
IF N = 5
PRINT "Hatchet Molly Attacks You."

ENDIF
IF N = 6
PRINT"Deadly Dallas Attacks You."
ENDIF
IF N < 1
PRINT "The Mysterious Glitch attacks You."
PRINT " "
sync
ENDIF
ATTACK = RNDRANGE (1,6)+1
;Print "NPC Number " + Str$(N)+" attacks you!"
PRINT " "
sync
;damage (HEALTH-ATTACK)
HITPOINTS=HITPOINTS-ATTACK
;adjust health
;report results
PRINT "YOUR HIT POINTS " + Str$(HITPOINTS)
PRINT " "
SYNC
WAIT 2000

;if_dead
IF HITPOINTS<1
PRINT "You're DEAD!"
PRINT " "
SYNC
WAIT 3000
ENDIF
IF HITPOINTS<1
Login required to view complete source code