Monday, August 15, 2011

CONT.... program changes and updates...

Hi Beth,

Hey, take a look at this new video that covers the movement of all the different transportation tiles.


The game is coming along but this movement test brought up a difficult problem I'm having. As you can see in the video I've been able to work out the movement and collisions of all the different types of player tiles. The one problem that came up is this:
Q: How do I place a transportation tile that is purchased on the screen and keep track of it when I move around the map and they tend to stay in location they were left last? Since I'm using this special data compression for the map tiles I don't have any idea how to place a ship for example on the map and be able to keep track of it when I move away from it. I need to be able to keep some sort of data record of all the different types of tiles like a horse or a cart or a ship and if don't board the tile I need to know exactly where it is if I move away from it and move back to it later. If a ship is left by a castle and I move to another world map should I use some array in basic to keep track of it? I was thinking that every time a purchase is made of one of the transportation tiles I could create a data files and enter that tiles as an array with an X,Y location. If the entire world map section is 180x80 and if the ship gets place near the castle then that would be for example 120x45 as a coordinate. I kind of understand how this may work but since I'm using this strange data compression format for the tiles I'm not sure how to make it so the ship will appear when it is close to the edge of the map. Am I explaining this right?
Q: I also see a problem if there are multiple purchases of a bunch of horses, ships, and other items that need to be tracked all the time so they show up when a character is near them on the map. What would the best way to do this: Assembly or Basic? In basic I can use an array and a write to a database file. In assembly I'm not sure without creating a bunch of unnecessary code!
Q: This also brings up monsters; they are going to be on the screen at different times and they also need the same type of tracking as transportation tiles. The problem with this is they move where the transportation tile don't! Do you have any ideas on how to cover either one of these ideas?
Thanks
Joe

++++++++++++++++++++++++++++++++++++++++++++++++++

Hi Joe,

Nice to see how smooth the graphics are turning out! So, one important question for you – are you utilizing page-flipping to draw your graphics? Because 1) you should be and 2) it will simplify the answer to your questions.

Basically, you show the user either page one or page two of the graphics while modifying the other page where they can’t see it. When you are done modifying it, you flip the pages, show the user the one that was hidden and resume the process. To quote from Wikipedia:

“The Apple II Hi-Res graphics mode did have one crucial advantage over IBM's CGA. Just as there are two text screen pages (and two Lo-Res graphics pages), so there are also two Hi-Res pages, mapped one right after the other in memory. (The second Hi-Res screen was mapped to 0x4000-0x5FFF, or 16384-24575 in decimal.) The CGA, on the other hand, supported only one graphics page at a time. Not until the EGA video card was released could the IBM platform support multiple pages of graphics simultaneously. Naturally, this simplified animation on the Apple II. A programmer could display one page while altering the other (hidden) page.”

Why is this important? Because your algorithm can look like this:

1.       Show user front-buffer graphics screen
2.       Draw all terrain on back-buffer graphics screen
3.       Draw transportation at locations on back-buffer
4.       Draw monsters at locations on back-buffer
5.       Draw player in center tile of back-buffer
6.       Switch user to be looking at back-buffer. Back-buffer is now front-buffer. Front is now back.
7.       Goto 2.

Do you need to keep a data file? Does it really need to be infinitely long? Couldn’t you just allocate say 10 or 100 entries for the x,y coordinate of the transportation type? 100 entries, 1 byte for type, 1 byte for x, 1 byte for y? So, 300 bytes? Do the same for monsters, provide perhaps 100 entries, for another 300 bytes somewhere. Make it so 0x00 for type is “none”. When the player buys transport or a monster appears, you scan through the array and replace the first 0x00 entry. When a monster is destroyed or transport disappears, you put 0x00 back in that array entry.

Then what you need to know is what the view coordinates are for the screen. So, for example, let’s say your screen is from 10,10 to 30, 20.  During step 3 in the above algorithm we would then loop through all 100 entries in the transportation list. For any non-zero type, you compare to see if the x coordinate is between 10 and 30 and if the y coordinate is between 10 and 20. If so, you draw it.

For step 4, you loop through the monster array the same way.

This nicely keeps your world-drawing/compression system separated from the update redraw of monsters/transport.

Sound reasonable?

-          Beth

No comments:

Post a Comment