Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Beginner's Guide To Dark Basic Programming Exercise Problem

Author
Message
VGHero11
13
Years of Service
User Offline
Joined: 15th Nov 2011
Location:
Posted: 21st Feb 2012 20:00
Hello again.

I have just finished a program from the dark basic programming book I'm going through, "Beginner's Guide To Dark Basic Programming" and I have problem with my code. I believe that I have retyped the code correctly but unfortunately when I run the game, one of the commands doesn't work. During the game, I have a code that will show that you have hit a certain character but for some reason it doesn't return the character.



When we all lend our power together, there is nothing we
can't do!
Please Lend me your STRENGTH!
Lucas Tiridath
AGK Developer
16
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 21st Feb 2012 21:10
Hi there. I'm not sure I know exactly what your glitch is. You seem to suggest that some characters aren't added to the list at the bottom of the game when they have been hit. However my test of it suggest that it works well. Maybe you could clarify which problem you are having trouble with?

The two issues I noticed were that the total hit counter was not incrementing (stayed on 0) regardless of how many you hit and some of the characters were drawn on top of each other in the list at the bottom of the screen that shows which characters you have hit.

I have resolved these two issues as follows. Your code to handle characters being hit read like this



where as in fact it should have been this



so this was why the counter wasn't incrementing. The reason the letters at the bottom overlapped is because you set the y value to 490 (thereby moving them to the bottom of the screen) with this line



but you do nothing to the x position. As the x position is generated randomly with this line



it means that characters that have similar x coordinates will be drawn on top of one another when there y values are made the same. I have fixed this using one method (there would be many solutions). My code is this:



As you can see, I use the unused 0 position in your CharCount array to keep a count of how many characters have been hit. I then use this as a multiplier to work out how far along the x axis the character should be placed.

This is the complete code:


I hope that helps. If you clarify exactly what issue you were having trouble with, I'll take another look and see what I can do .

Wamphyri
12
Years of Service
User Offline
Joined: 29th Jan 2012
Location:
Posted: 22nd Feb 2012 20:02
Ok first I see

CharCount(1) = 0

should be = 1 not 0

then

charspeed(x) = 1

should be = RND(6) + 1

then

LINE 639,0,charx,chary(x)

should be LINE 639,0,charx(x),chary(x)

then

hitschars(1) = hitschars(1) = 1

should be

hitschars(1) = hitschars(1) + 1
VGHero11
13
Years of Service
User Offline
Joined: 15th Nov 2011
Location:
Posted: 22nd Feb 2012 20:24
Thank You Lucas. I think I confused myself with what was written in the book and what the program was doing.

When we all lend our power together, there is nothing we
can't do!
Please Lend me your STRENGTH!

Login to post a reply

Server time is: 2024-11-22 05:43:28
Your offset time is: 2024-11-22 05:43:28