Iadvd / RetrocomputingZXSpectrum

Example applications to be used with the Android TCP/IP Virtual Joystick application
GNU General Public License v2.0
19 stars 3 forks source link

technical question #3

Closed fraespre closed 4 years ago

fraespre commented 4 years ago

Hi iadvd (extrange nick),

I would like to ask you about how have you integrated the "star field" with the SPLIB graphics in the FederationZ. Because, I know that the SPLIB uses a graph buffer, and each time it dump the buffer to the screen everything over-writing. Do you draw the "star field" into the buffer ? I guess that not, so I think you draw the SF just after to the "updateNow" command of the SPLIB.

Thanks in advanced and greetings from Spain,

Iadvd commented 4 years ago

Hola! caramba no recibo notificaciones de preguntas, la encontre de casualidad!! IADVD means "I Am DaViD". I will answer in English so everybody can follow us... well, the reality is that my solution writes DIRECTLY at the screen. I just make the sp_Update() of the contents of the SPLIB buffer, and OVER it I update the stars at the screen address. How can I do that? I have made a trick: EVERY tile of the game does NOT have any single pixel or a couple of pixels together, alone in one byte (8 pixels) line of the image. So if you check the static tiles, or the tiles of the sprites, no one has a single byte line of pixels containing just a single pixel (like this: 00000001, 00000010,00000100,00001000,00010000,00100000,01000000,10000000) or two pixels together (any combination like this: 00000011, 00000110,00001100,00011000,00110000,01100000,11000000). It does not matter if you have any other combination. Then, when you move the stars and you want to write it in a new position, first you remove it from the current position. But if in the current position the byte of the image is not a pixel or a double pixel alone like the examples above, then means that there was another thing there (a planet or whatever), not a star, so no need to remove the star from the current position, because it was not being shown. Then next step is writing in the next position according to the movement of the star ship, so again the same rule: if in the target new position there is a byte of image containing something different from a "00000000" byte or a single pixel or a double pixel alone like in the samples above, then you do not need to write the star because there is something there (a planet or whatever, so it is BEHIND that object). Of course you keep in memory the new position of the star for the next movement, but you do not show it). Espero que no sea muy complicado de seguir! Greetings from Tokyo!!

fraespre commented 4 years ago

Thank you very much David for your detailed explanation. It sounds more complicated than I initially thought.

I have to admit that I was looking at the code, and there are parts (like the star field) that I found difficult to follow because you have done some tricks to reduce memory space (which you had already commented in the interview with Javi Ortiz).

Anyway, it's a very interesting game, breaking the monotony of the platform type. Congrats for your work.

さようなら友達

Iadvd commented 4 years ago

Thanks for your comment, I was fighting with this game 6 months... usually a MK1 game needs around two or three months of time to prepare everything... this one was at the verge of not being finished! I did not find any clear asm code example to make a star field, so I just decided to go ahead with my own idea... probably there is a better way to do it. Basically there are two types of stars in my star field, one pixel star and two pixel stars. One pixel stars if you move the ship will move one pixel to the left right up or down, if they are two pixel stars they will move two pixels to the left right up or down... in that way you get a two layer "parallax" effect. The one pixel stars are far away, they move slower, the two pixel stars are closer, they move "faster". The third layer are the planets and comets, etc. those objects are even more closer so they move 8 by 8 pixels left right up and down... every time I touched something a new bug appeared, so it was not easy at all. 宜しくお願いします。;)

fraespre commented 4 years ago

The result of your star field has been very pretty. The idea about to use 2 pixels for the closer layer (of the star field) is clever.

If you allow me a suggestion, I would have incorporated an inertial motion to the ship, to give a more realistic feel.

In case you are interested, today this video has been uploaded on how to make a start field using ECS. Take a look, basically what may interest you is how to structure the code towards the ECS paradigm. [ MK1 isn't ECS, but may be in the future you choose make your creations without the MK1 rails :-p ] https://www.youtube.com/watch?v=ighkMUM9-Ww

私はこれらの小さなシンボルが大好きです