Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASCII collision detection help.

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi, I'm new to QB and I making an ASCII type game, I'm having a bit of trouble implementing an efficiant collision detection routine, any one know of some code that could help?
 
if u're using ASCII for the game, i assume that you'll be running on text mode.

u can use the x and y position of your ASCII 'character', and check for collision if the position is the same.

good luck. ----------------------------------------
There's no good nor evil, it's all in the mind.
 
Suggestion: Read your help files regarding the SCREEN function (not the SCREEN statement)

--MiggyD It's better to have two heads to solve a problem from different angles than to have tunnel vision to a dead end.
 
Miggy D - what do u mean SCREEN function? - I've never used it (not knowingly anyway) and it ain't in my help file.

Pomsane - if I were you, i wouldn't use ASCII code - i would use graphics they are easier to move around (with the GET and PUT statments) and much funner to watch :p Anyway this is the code I have used to make games with collisions: demolition derby, pong, war

IF x1 = x2 THEN IF y1 = y2 THEN GOSUB collision

Its pretty straight foreward
 
To Pomsane:

If you do not understand what we are talking about, you will need to post the area of your code that you are having problems with. Most often, students will arrive here with homework assignements and simply expect someone else to do the work for them. All the while, the students just lay back and learn nothing. That is why you should place some code... so that others can guide you in the right direction without belittling your compentency and knowledge.


To qbasicking:

Now, if you are using QB 4.5, open up HELP>INDEX and press the letter 'S'. You'll see them both listed. Also, if you type in SCREEN and F1 it...click on the help window and move the cursor ALL THE WAY TO THE BOTTOM OF THAT WINDOW...and you'll note that there's a statement to the affect of 'Other uses of SCREEN keyword' (or something like that X-) ).

As for QB 1.0/1.1, I don't recall off-hand where it is located; but, I do believe the functionality is there, and therefore must be listed somewhere in the help files. Check out the Index section--it may be there.

See if you can find the SCREEN FUNCTION in the following short program.


' --- Start copying here ---
CLS
SCREEN 12
FOR Cycle = 1 TO 26
PRINT CHR$(64 + Cycle);
NEXT Cycle
DO
LOCATE 4, 1
INPUT "Enter a number (1 - 26): ", GetThisOne
IF GetThisOne AND (GetThisOne > 26) THEN
LOCATE 4, 1
PRINT STRING$(77, 32)
GetThisOne = 0
END IF
LOOP UNTIL GetThisOne
ReturnedWord$ = CHR$([red]SCREEN[/red](1, GetThisOne))
PRINT
PRINT
PRINT "You choose the letter...";
COLOR 14
PRINT ReturnedWord$
LOCATE 1, GetThisOne
PRINT ReturnedWord$;
COLOR 15
END
' --- Stop copying here ---


Hope this has enlightened you.

--MiggyD It's better to have two heads to solve a problem from different angles than to have tunnel vision to a dead end.
 
Thanks guys, I did a bit of research into the SCREEN function, it worked out great!
 
Your welcome.
--MiggyD It's better to have two heads to solve a problem from different angles than to have tunnel vision to a dead end.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top