Tinycloud778 2019-06-04 01:58
A world generator using text, in the meanwhile I will try to figure out how to print the string and keep the colors of the different text
Timo 2019-06-04 06:02
Colors cannot be stored directly in a text string, it wouldn't be possible to just PRINT a colored text. A trick could be using CHR$(n) to store numbers into a string, but 0 is not supported.
Probably the best way to store a map is to write everything into a two-dimensional array (DIM). This may require another DIM tutorial though...
Or you store it in working RAM using POKE in the format of the BG Designer, then you could even use BG COPY to draw it. But it's a bit complicated.
These are just ideas, sorry, I don't have time now to explain more.
was8bit 2019-06-04 06:40
CA=CELL.A(X,Y) should give the color of a location
CC=CELL.C(X,Y) gives the character number of a location
This code should yield the string character on the screen...
IF CC>=192 then CCHAR$=CHR$(CC-160)
Then you could do comparisons...
IF CCHAR$=“*” AND CC=0 THEN
but CC only going to reference the pallete number, not which of the 3 colors inside the pallete...
If this approach would work, you can use the screen itself as the memory, and avoid having to is an array.. ;)
was8bit 2019-06-04 06:41
.. so I see you are using ATTR(4), ATTR(5) and ATTR(6) .. CC will then return either 4,5,or 6
was8bit 2019-06-04 06:44 (Edited)
So, i see what you are trying to do, I have an idea... I’ll post it soon....
was8bit 2019-06-04 07:03
Check this out... I used ALL of the tricks i know... it does what you want..l if you can learn how to use SUB ... you’ll find it to be VERY powerful :)
was8bit 2019-06-04 07:09
Basically, what I’ve done is changed WORLD$ into TWORLD$, meaning it is storing the TEXT, and added CWORLD$, which is storing the color information in text form by using STR$ to change the number of the color, say 6 into a string, say “6”...
Then I use a fancy method of “reading” each entry stored in each string... so rather than printing out the map in one shot, you have to read each one text, read what color it should be, set the color, calculate its location (using the math tricks i added) then printing the text in its original position.. ;)
was8bit 2019-06-04 07:17 (Edited)
A SUB has inputs... so if you are doing the same thing, just using different inputs, a SUB can be a very powerful tool you can create and use...
So, for each new random text/color pair,,although the text and color may be different, we are doing the same things with them.. the text (and color) is added to the main strings (TWORLD$,CWORLD$) and we are putting that colored text on the screen...
So, we capture the repeated action inside the SUB, and then when we use the CALL (sub name) we can input the different inputs into the SUB, which uses whatever the values for the inputs are, and processes those inputed values for us...
was8bit 2019-06-04 07:26
An advantage of SUBs is that variables inside subs are “secured” inside the SUB only, so,variables inside the SUB act like a seperate little program.. so if you want any normal variables in your main program to affect or be affected by the SUB, you will notice that I have GLOBAL TWORLD$,CWORLD$... this means these 2 variables can be used by all SUBS and by the main program...
Otherwise, all variables used inside a SUB cannot be seen by the main program or by any other SUB... a SUB is like a seperate little program whose insides do not really exist to the main program ... it’s kinda like you are creating your own powerful command... ;)
Tinycloud778 2019-06-04 15:08
Ok awesome, thanks
was8bit 2019-06-04 15:24