Page 1 of 1

Games in text mode and collisions

Posted: Mon Jun 30, 2025 8:35 am
by softmosquito
I'm trying to make a simple game that I had already made in the 80s with the Vic-20. In the initial version the game was created with only text characters and no sound. It was just to test the operation and playability. Then I made the graphic version with sound and some words of digitized speech.
Here, I wanted, with ugBASIC, to redo the same simple version in character mode. I have a bit of everything but I lack the collision control. In the text version in the 80s I checked if the position where I had to write a character was already occupied: if there was something other than space then there was a collision. But in ugBasic how can I check this? I understand that the text mode is actually a graphic mode too. There is the POINT function but in this case it is not useful to me because in the tests it always returns 3.
Probably the way I structured the program (which was meant to be simple, just for testing) is not good, I have to think of everything in a different and more complex philosophy.

Re: Games in text mode and collisions

Posted: Mon Jun 30, 2025 9:01 pm
by spotlessmind1975
Hi softmosquito, and thank you for your message! :)
softmosquito wrote: Mon Jun 30, 2025 8:35 am Here, I wanted, with ugBASIC, to redo the same simple version in character mode. I have a bit of everything but I lack the collision control. In the text version in the 80s I checked if the position where I had to write a character was already occupied: if there was something other than space then there was a collision. But in ugBasic how can I check this?
If I understand correctly the issue, you need an instruction that identifies which character is contained in a certain position on the text screen. In that case, you could use the SCREEN' function, that allows you to know the content of the text memory at a specific position. There are two versions of this function: one without the dollar ($) symbol, which returns a 'BYTE' with the value, and one with the dollar symbol, which returns a string with that value.

This is an example:

Code: Select all

CLS
LOCATE 1,1
PRINT "A"
LOCATE 2,2
PRINT SCREEN(1,1): ' this will print 1
Note that the command returns not the ASCII code but what is called the SCREEN CODE, which is different from computer to computer. For example, 1 = "A", 2 = "B", and so on. For the same reason, if you use SCREEN$, you will get a string with the character CHR$(1), which is not printable.

Re: Games in text mode and collisions

Posted: Mon Jun 30, 2025 9:21 pm
by softmosquito
Wow! That's right! It works! Thank you so much!