This is not a game; it is a demo of some ways to display visual output to a game user. The demo uses three graphic boxes to display Life Force, Ammo, and Enemy Kills for the player. Because there is no actual game, I used RND(0) for the value of Life Force and damage inflicted on the Klingon target. The highest score will be the winner.
Before Captain Kirk can fire on the Klingon ship, he must lower his shields, making him vulnerable to enemy hits while firing. If the Enterprise suffers a hit, she can still fight while Scotty's Engineering Department is working on repairs. When Life Force is less than 50%, it is critical and displayed in red. By design, Life Force cannot drop below 30% so you will not be killed or injured during play.
Ensign Checkov fires the torpedos, and there is a delay between shots while the Enterprise is reloading. Even if Checkov scores a direct hit, the Klingon ship may have its shields up. Only one out of ten "hits" will destroy the Klingon ship. When Checkov has fired all available torpedos, "Out of Ammo" flashes 20 times and the game is over.
Enemy kills are displayed as text over an image of a Klingon ship. Originally I had thought to display an image for each kill, but that would have required a tiny image if the player makes a lot of kills, so I decided to use a larger image and display successive kills as text. For this demo, the image is drawn off-screen at start up, and printed only when the first kill is made.
Okay... this is not a game, merely a demo of several methods to present visual output to the user. You can adapt any of the code blocks for use in your game, and even come up with more methods of your own! You should be able to "copy and paste" this code from the web page to your code editor and run it "as is." No other files will be needed.
'Multiple-Graphic Displays
'Game is over when out of ammo
'by Welopez, 071506
GOSUB [drawSaucer] 'Create the image for kills box
NOMAINWIN
rnds=50 'starting position for Ammo display
WindowWidth=608
WindowHeight=300
UpperLeftX=INT((DisplayWidth-WindowWidth)/2)
UpperLeftY=INT((DisplayHeight-WindowHeight)/2)
BUTTON #status.btn1, "QUIT", quit, LL, 170, 0, 60, 30
BUTTON #status.btn2, "SHOOT", [shoot], LL, 370, 0, 60, 30
GRAPHICBOX #status.bx1, 2, 5, 196, 200
GRAPHICBOX #status.bx2, 202, 5, 196, 200
GRAPHICBOX #status.bx3, 402, 5, 196, 200
OPEN "STATUS" FOR WINDOW AS #status
PRINT #status, "trapclose quit"
PRINT #status.bx1, "DOWN"
PRINT #status.bx3, "FILL 255 255 200 ; BACKCOLOR 255 255 200"
[shoot]
PRINT #status.bx1, "FILL 255 255 200 ; BACKCOLOR 255 255 200"
PRINT #status.bx2, "FILL 255 255 200 ; BACKCOLOR 255 255 200"
PRINT #status.bx1, "COLOR green"
PRINT #status.bx1, "PLACE 20 20"
PRINT #status.bx1, "FONT tahoma 12 bold"
PRINT #status.bx1, "\Combat Readiness"
PRINT #status.bx2, "COLOR blue"
PRINT #status.bx2, "PLACE 70 20"
PRINT #status.bx2, "FONT arial 12 bold"
PRINT #status.bx2, "\Ammo"
PRINT #status.bx3, "COLOR red"
PRINT #status.bx3, "PLACE 80 20"
PRINT #status.bx3, "FONT verdana 12 bold"
PRINT #status.bx3, "\Kills"
GOSUB [update]
PRINT #status.bx1, "FLUSH"
PRINT #status.bx2, "FLUSH"
PRINT #status.bx3, "FLUSH"
WAIT
SUB quit handle$
'"saucer.bmp" is not loaded from file and does not require UNLOADBMP
CLOSE #status
END
END SUB
WAIT
[update]
'the Life Force display
PRINT #status.bx1, "PLACE 55 120"
PRINT #status.bx1, "FONT arial 48"
lf=INT((RND(0)*70)+30) 'the Life Force value
IF tammy=0 THEN lf=100 'Life Force is 100% on initial run
IF lf<50 THEN PRINT #status.bx1, "COLOR red"
PRINT #status.bx1, "\";lf
PRINT #status.bx1, "PLACE 10 175"
PRINT #status.bx1, "PLACE 5 140"
IF lf<50 THEN 'change color if Life Force less than 50%
PRINT #status.bx1, "BACKCOLOR red" 'indicates a dangerous condition
ELSE
PRINT #status.bx1, "BACKCOLOR green" 'the default color
END IF
PRINT #status.bx1, "BOXFILLED "; (lf*190)/100; " 155"
PRINT #status.bx1, "BACKCOLOR 255 255 200"
PRINT #status.bx1, "PLACE 10 185"
PRINT #status.bx1, "FONT arial 14"
PRINT #status.bx1, "\0%"
PRINT #status.bx1, "PLACE 140 185"
PRINT #status.bx1, "\100%"
'the Ammo display
PRINT #status.bx2, "DOWN"
PRINT #status.bx2, "PLACE 30 50"
PRINT #status.bx2, "\100%"
PRINT #status.bx2, "PLACE 30 185"
PRINT #status.bx2, "\0%"
PRINT #status.bx2, "BACKCOLOR blue"
rnds=rnds+2
PRINT #status.bx2, "PLACE 120 "; rnds 'rounds increases, ammo decreases
PRINT #status.bx2, "BOXFILLED 150 185"
IF tammy>0 THEN
PRINT #status.btn2, "!disable" 'disable button while waiting
linda=INT(RND(0)*10)+1
IF linda>=9 THEN
GOSUB [score] 'only 1 shot in 10 will score
ELSE
PLAYWAVE, "C:\Program Files\Windows NT\Pinball\SOUND29.wav", asynch
END IF
TIMER 1000, [resume] 'timed pause between shots
WAIT
[resume]
PRINT #status.btn2, "!enable" 'enable button for next shot
TIMER 0
END IF
IF rnds>=184 THEN
PRINT #status.btn2, "!disable" 'disable button; game has ended
WHILE k<25 'setup flashing routine
k=k+1
IF barbara=0 THEN
PRINT #status.bx2, "BACKCOLOR 255 255 200"
PRINT #status.bx2, "PLACE 40 120"
PRINT #status.bx2, "COLOR red"
PRINT #status.bx2, "\OUT OF AMMO!" 'show message
barbara=1 'set barbara
ELSE
PRINT #status.bx2, "PLACE 40 120"
PRINT #status.bx2, "\"; SPACE$(30) 'hide message
barbara=0 're-set barbara
END IF
TIMER 200, [continue]
WAIT
[continue]
TIMER 0
WEND
END IF
tammy=1
RETURN
'the Kills display
WAIT
[score]
PRINT #status.bx3, "PLACE 50 50 ; DRAWBMP saucer.bmp"
PLAYWAVE, "C:\Program Files\Windows NT\Pinball\SOUND50.wav", asynch
sum=sum+1
PRINT #status.bx3, "FONT arial 28 bold"
IF sum>9 THEN
PRINT #status.bx3, "PLACE 78 122"
ELSE
PRINT #status.bx3, "PLACE 88 122"
END IF
PRINT #status.bx3, "BACKCOLOR 230 230 230"
PRINT #status.bx3, "\";sum
PRINT #status.bx3, "COLOR red"
PRINT #status.bx3, "BACKCOLOR 255 255 200" 'restore text background
PRINT #status.bx3, "PLACE 80 20"
PRINT #status.bx3, "FONT verdana 12 bold" 'restore text
PRINT #status.bx3, "\Kills"
PRINT #status.bx3, "FLUSH"
RETURN
WAIT
[drawSaucer]
'create temporary window to draw BMP
'draw a sort of silly space ship
NOMAINWIN
WindowWidth=400
WindowHeight=400
UpperLeftX=INT((DisplayWidth-WindowWidth)/2)
UpperLeftY=INT((DisplayHeight-WindowHeight)/2)
OPEN "SpaceShip" FOR GRAPHICS_nsb AS #g
PRINT #g, "trapclose [quitg]"
PRINT #g, "DOWN"
PRINT #g, "FILL 255 255 200"
PRINT #g, "BACKCOLOR 230 230 230"
PRINT #g, "PLACE 175 180"
PRINT #g, "ELLIPSEFILLED 15 100"
PRINT #g, "PLACE 205 180"
PRINT #g, "ELLIPSEFILLED 15 100"
PRINT #g, "PLACE 190 200"
PRINT #g, "PIEFILLED 85 100 160 220"
PRINT #g, "GETBMP saucer.bmp 140 120 100 100"
CLOSE #g 'we don't need this window any more
RETURN
The sound effects for this demo are probably included with every version of Windows XP and WAV files do not need to be included for the demo. If you don't have XP, you can insert your own WAV files by changing the paths in the code. If you don't have the specified WAV files on your computer, no error will be generated, you simply do not hear the sounds.
Because the image of the Klingon ship is drawn in a GOSUB at program start, image files do not have to be downloaded for the program.
I'm sure someone will ask, "What are Barbara, Linda, and Tammy doing in this code?" They are flags, to get attention and do something during program execution. Few things get my attention quicker than a pretty girl, so I added a little humor by using a few names from Don Juan D'Worbles little black book.
This is just a demo to answer some of the questions I've seen posted on the boards. You don't have to use any of these methods, perhaps you'll have a slicker way to present the display. The real work begins when you write your program: Does your warrior have a sword? Can it pierce the bad guys armor? Is there a Wizard to provide medical help and heal wounds? How can the warrior get more arrows? All that is up to you, as well as designing the field of combat, whether it's deep space or a dark and brooding forest filled with gnomes, fairies, and evil trolls. You need to have a game before you can keep score and designing the game is where you show your creativity!