• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

scoring in a QB bowling game

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

MadSkillzMan

Member
Joined
Nov 16, 2003
Location
Cleveland OHIO
hey, ive been working on a bowling game in qbasic for about 2 weeks.. Its pretty good, ..pretty similar to all the other games out there you see...im very close, my only problem is the scoring. I need to have a way where if a pin gets nocked down after the first ball throw, it cant be scored the 2nd time around. I was starting to use an array, and set it from 1 TO 10. if a pin is standing, the array(x) will equal 0, but if it fell, it will equal 1, and 1 would be added to the score. but im stuck, i need some ideas on how to have it recognize that its the 2nd ball, and what pin has been nocked over already. if anyone can just gimmie alittle direction itd be greatly appreciated..im very close..thank you
 
Seems to me that you have everything you need right there. You know its the second ball if any of the array elements are 1 rather than 0. The array index tells you which balls have been knocked over already. Here's some pseudo code to explain:
Code:
    n = number_of_ball_hit;
    if balls_already_hit[n] equals 0 then
        score = score + 1
 
it is hard to describe.....ok now that im more awake ill give an example...

say u throw the ball the first time and u go right down the middle and get a 7/10 split. Now say u throw the second ball, at the SAME place, it will go to the end and hit nothing, BUT it will still score as hitting 7 of the 10 pins.

what i was going to do w. the array was, set each variable of the array 1-10 to zero at the beginning of each frame. Then once u bowl your first ball of the frame, depending on which pins are hit, it will set the number of the array to 1.

the only thing i can think of is a TON of IF THEN statements comparing weather it is the 1st or 2nd ball of the frame, and which pins wer hit...

if that doesnt help its ok lol itsa problem i can hardly explain to anyone unless they wer sitting there watching me as i made it..thanx for ur hlep
 
You need more than two states for the pins in your array. If you use 0, 1 and 2, then it becomes easier. 0 means the pin is still standing, 1 means it was knocked down on the first ball, and 2 means it was knocked down with the 2nd ball. Scoring then becomes simple. Then you just add up where you have a 1 for ball 1, and a 2 for ball 2:

(pseudocode)

dim pinarray(10)
ball1score=0
ball2score=0
for x = 1 to 2
for y = 1 to 10
if x = 1
ball1score = ball1score + iif(pinarray(y)=1,1,0)
else
ball2score = ball2score + iif(pinarray(y)=2,1,0)
endif
next y
next x

strike = iif(ball1score=10, 1, 0)
spare = iif(ball1score+ball2score=10 and ball2score > 0, 1, 0)

Assuming you can use immediate ifs in QBasic. I've never programmed in QBasic, so I don't know. Either way, you can accomplish the same thing with regular ifs.
 
u know what......that makes ALOT of sense and my life ALOT easier lol thank u very much i will get working on this this weekend....it isnt due for about 2 weeks...so i figure get it done, then go back and make it look nicer..its ok now..but the pins could be more definite...and ill add mouse support for the main menu and all of that..THANK U!!!
 
Ok guys, got it to work! Yea, i ran close on time and gave into MANY MANY IF THEN statments. Scoring isnt very accurate when it comes to spares and strikes. Ill work on that later. But i will upload it somewhere for you guys to try.

Theres only one other guy in my class witha working game. He did 2 player snake. Its awsome, i found a gif loader online and had little luck w. it, so i gave it to him. Took him 3 weeks and almost cost him his game but he got it to work. So the menu and credits are insainely awsome, but the game is atari style. Nothing wrong with that, VERY addicting.
 
The way I would have done it is to wait until after the second ball was thrown to add up the score.

One thing I've learned is that if you write complex code, like your many if statements it becomes very hard to modify. If you have to change 20 if statements to get the strikes working, it might be more work than rewriting the scoring mechinism in a simplier way and only having to change a few statements.

It is also much easier to solve problems when the occur. If you make a mistake in the if statement for the 3 pin, you may never see it when you are testing. If you make a mistake in an if statement that applies to all 10 pins you are 10 times more likly to catch it when you are testing.
 
Yea, the strike and spare just add like 10 or 20 to your score. I wil perfect it of corse, even though its already turned in and done. Once i get my 2nd PC moved onto the same desk as my main it will be much easier to work on.
 
Back