Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: c.sprinkle on January 11, 2011, 05:28:42 pm

Title: I: VP tilemap help!
Post by: c.sprinkle on January 11, 2011, 05:28:42 pm
Tilemap Problems:

1). What Format To Use
Option 1: Scroll 8 pixels at a time only when you reach the edge of the screen. The easiest, but it won't look as nice.
Option 2: Scroll 1 pixel at a time when you reach the edge. I would need to work that out a little more fully.
Option 3: Scroll 1 pixel at a time when 8 pixels from the edge. Beautiful, but I need some help with learning to do that.

2). How can I scroll without clearing the screen?

3). I would like better wall sprites. . .
Title: Re: I: VP tilemap help!
Post by: yunhua98 on January 11, 2011, 05:55:32 pm
1)  well, its easier and looks pretty good if you only move the map and keep the character on the center of the screen.
2) You'll have to use a map display routine.  I can give you a specific example or someone else could if you elaborate more.  (I'm also interested in tilemapping routines from other people if they don't mind sharing.  I don't think mine's very efficient  :P)
3) same here.  :P  You don't really always need a wall though...

EDIT:  for #2, update the screen only when you move or when there is a moving person or something.  ;)
Title: Re: I: VP tilemap help!
Post by: FinaleTI on January 11, 2011, 06:15:55 pm
For map formats, if you aren't using greyscale (which I believe you are), I can do some pretty wacky stuff with pics.
Title: Re: I: VP tilemap help!
Post by: Michael_Lee on January 11, 2011, 06:22:37 pm
2) You could try using the Horizontal and Vertical commands, then displaying only the necessary sprites to draw on the side that you need to fill.  I think Runer's uber-optimized tilemapper uses that method, although I personally haven't had the fortitude to attempt coding such a thing...
Title: Re: I: VP tilemap help!
Post by: c.sprinkle on January 11, 2011, 07:06:16 pm
Yeah, I guess I'll try that. Now for more reliable collision detection. . .
Title: Re: I: VP tilemap help!
Post by: Ashbad on January 11, 2011, 07:15:07 pm
one thing that improved trio and niko's framerate from about 5fps to 45 fps was by only redrawing the screen WHEN YOU ABSOLUTELY HAVE TO.  If the screen doesn't scroll or the map doesn't change, then just store the buffer to the back buffer using storepic and then recallpci when no redraw is nessicary.
Title: Re: I: VP tilemap help!
Post by: yunhua98 on January 11, 2011, 07:18:51 pm
Or just don't update the screen at all until you move.
Title: Re: I: VP tilemap help!
Post by: Ashbad on January 11, 2011, 07:26:47 pm
well, even wen your moving, if the screen doesn't scroll, no need to re-map :P
Title: Re: I: VP tilemap help!
Post by: c.sprinkle on January 12, 2011, 01:52:59 am
Yup, I'll only redraw when I scroll. And even then, I'll just use Horizontal and Vertical commands and then redraw the new tiles. It's fast right now, though. My battle engine is coming along well, too.  :)
Title: Re: I: VP tilemap help!
Post by: c.sprinkle on January 13, 2011, 04:33:44 pm
Look, a double post! (It's been more than 6 hours.)

For some reason I can't make store more than 110 bytes of data to one GDB location in Axe. Anyone know how to fix that?
Title: Re: I: VP tilemap help!
Post by: yunhua98 on January 13, 2011, 04:40:10 pm
well, even wen your moving, if the screen doesn't scroll, no need to re-map :P

in my RPG, your character is fixed, and it always scrolls when you move.
Title: Re: I: VP tilemap help!
Post by: DJ Omnimaga on January 17, 2011, 03:48:40 pm
For scrolling the trick is to shift the screen content in the direction you want to scroll and only draw the new line of tiles instead of redrawing the entire 13x9 tilemap every frame. In a side-scrolling game (left-rigth only) I wonder if it's faster to simply move the content of L6 one byte up/down, though, then simply display the new line of sprite afterward.
Title: Re: I: VP tilemap help!
Post by: c.sprinkle on January 17, 2011, 06:10:53 pm
Just wondering:
Ashbad, Squidget, how do you do the enemy moving routines?
I have an idea, but I'm not sure if it will work. . .  ???
Title: Re: I: VP tilemap help!
Post by: squidgetx on January 17, 2011, 06:35:37 pm
My enemies don't move in the overworld; the battles are more like pokemon :P

I would probably have a max number of enemies onscreen (lets say 4) then a byte determining what type, 2 bytes for x and y position, maybe a byte for health, and then randomly increment x,y positions. But I thought you were going turn based battle style?
Title: Re: I: VP tilemap help!
Post by: yunhua98 on January 17, 2011, 06:38:58 pm
Well since he can swing a sword in the overworld, I guess he can.  TaN:F has overworld enemies though.
Title: Re: I: VP tilemap help!
Post by: c.sprinkle on January 18, 2011, 10:10:36 am
I am using a turn-based system, but I was just wondering whether to have enemies move around and attack or not. Then you go to the turn-based system. If they don't move, it would probably be too easy to get around them.  :-\
Title: Re: I: VP tilemap help!
Post by: Ashbad on January 18, 2011, 10:29:40 am
EDIT: wow I posted a lot of stuff :/  didn't know it was THIS much


I think I know what you mean though: Zelda II style of encountering enemies :D  Where the enemies move around on the map liek you, but you don't fight them until you and them meet on the overworld map.  Then the action begins.

I can give you some guidance on how to do moving enemies on an overworld map.  My enemies are all 8 bytes large in data each, in this format:

byte1: enemy type, 0 if null
byte2: enemy x
byte3: enemy y
byte4: enemy health
byte5: extra byte, used for type-specific actions
byte6: direction of enemy
byte7: enemy movement counter
byte8: counter for whether the enemy is flashing after taking damage

Basically, you have to initiate all the enemies you want to have with stats you decide on (I suggest no more than 3 enemies -- that can get rather slow rather quick)

Once you do that, here is what you can do:

Code: [Select]
...Enemies...
Lbl ENE  //label here for me, because I used the enemy loop as a subroutine
For(A,0,2)  //A loop that loops for every enemy you have, in this case 3
If {A*8+L1+400}  //Pretending that each enemy's stats are 8 bytes large and L1+400 to L1+423 is where the stats are held
//That also makes sure it's doing the following steps for an actual monster, not some random stats with no enemy type
(Here you do your method of collision detection, similar but not as advanced as for your avatar)(
(Here you see if your avatar and the enemy collide, and then the actions)
(Here you can do other stuff like changing directions and moving)
End
End  //End of For statement

^basic format of dynamic enemies on the overworld

The moving stats and stuff for my enemies take up no less than about 100 lines, so I won't go through them here; but I can give you more tips on how my format works great:

Really quick  --  make sure the bytes of stats enemies take up are a power of 2 for best speed (like 4, 8, or 16)
Accessibility --  to get to a stat easily, just do something like {A*8+L1+400+ (byte number of stat you wish to access - 1)}
Optimizational -- while this is already fast in {Loopvar * statvars_size + buffer + offset} format, you can always change something like:

Code: [Select]
If {A*8+L+403} < 5
0 -> {A*8+L+403}
Else
{A*8+L+403} - 1 -> {A*8+L+403}
End

to:

Code: [Select]
{A*8+L+400} -> H
If {H+3} < 5
0 -> {H+3}
Else
{H+3} - 1 -> {H+3}
End

cutting out half the size and speed.



If you have any more questions, feel free to post them, I can help you with anything you need! :D
Title: Re: I: VP tilemap help!
Post by: c.sprinkle on January 18, 2011, 10:44:54 am
Yep, I always use the {ptr}->indicator var so I don't have to type it back in and leave more room for things I have to change in case of size increases of the tilemap, etc. The beautiful thing is that my enemies only have to have a few bytes. So:
byte0- type
byte1- x
byte2- y
byte3- direction

The enemy collision will be part of the normal check. The stats are loaded by the battle engine.
Title: Re: I: VP tilemap help!
Post by: DJ Omnimaga on January 18, 2011, 03:24:11 pm
If you mean enemies that shows up on the map while walking around, it is fine if they don't move, like in Final Fantasy Mystic Quest, but as long as you make sure a lot of them block pathways, to force the user to fight them. Moving enemies like in Lufia II or Super Mario RPG is another idea.