Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / scrolling map Help

Author
Message
zeddex2
17
Years of Service
User Offline
Joined: 4th Mar 2007
Location:
Posted: 11th Nov 2008 02:46
Hi everyone

Ok I know we have many post about scrolling tile map on the forum. But none of them answer my question.

I still don't anderstand the basic ( I know how to deal with variable, array and etc.. )

I still don't anderstand the basic of how your tile move with your sprite in the middle, when you reach the border, your sprite move and the tile stop.

How you can make your NPC sprite move on your tile when they are not showing on the screen.

I think from my point of view and plz tell me what is wrong in my logic.

To make your tile move: you have to know how many tile you print on your screen (ex: on a reso of 800x600 = 25 tile x 18.75 tile)

if a directionnal key is pressed: you have to move the entire tile position by the movement (ex: if left key press and move for 25 px, you have to make all the tile move for Y + 25)

For NPC movement: I think I have to put a vaiable for each tile

(ex: 1 - 2 - 3 - 4 - 5
6 - 7 - 8 - 9 - 10
11 - 12 - 13 - 14 - 15)

and if my main toon move from tile 8 to 7, I have to saved all npc on the tile they are, move all my tile for the same number of px, and put my NPC on the tile at the new position before refreshing my screen. ?????

Is that the basic of a normal scrolling tile system ???

(my goal is to make a Zelda kind of game, not a copy with sprite but only the style, main toon, quest with dongeon and items etc..)

thank for the help guy.

If you can, I can!
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 11th Nov 2008 16:59 Edited at: 11th Nov 2008 17:08
Are you looking for smooth scrolling (per pixel scrolling) or can the map scroll an entire tile when you reach the edge?


Or are you looking to do something similar to theoriginal NES Zelda, where each screen get's loaded?

"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin
zeddex2
17
Years of Service
User Offline
Joined: 4th Mar 2007
Location:
Posted: 12th Nov 2008 23:19
technicaly i want to make something like zelda on the Snes.

If you can, I can!
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 12th Nov 2008 23:45
Well I can code up something quick and dirty when I get home. Shouldn't take me more than an hour or so. Unfortunatley I lost all my old work on an external HD that went south (remember to backup your work friends). I get off work in 15 minutes, And I'll post as I go along.

"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 14th Nov 2008 04:06 Edited at: 18th Nov 2008 01:03
Sorry didn't get a chance last night, and I had to hunt down some sprites and reorganize them.

EDIT:
Just thought about it, and now I'm not sure if it's ok to post sprite rips here. I would only be using them as an example, but if it's not permitted I'll remove them and use less desirable sprites.





"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Nov 2008 10:46
Check out my code base entry, it can do what you want.


http://www.thegamecreators.com/?m=codebase_edit&i=a4c8368a3859cb0ed738047a9b88cbc6


zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 16th Nov 2008 16:06
Thanks Phaelax. I too will have a look at your code. I haven't forgotten about this, but I figured it would be better if I took the time to code it properly. Sometimes whipping up a quick snippet, can do more harm than good, and lead someone down a path that the code will be unmanageable as they get more involved. I have off tomorrow and tuesday, so I'll have something up by then.

"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 18th Nov 2008 00:59
Just getting started today.

The code is in an early temp stage but I'll get it there. For now I just extracted Links basic frames, and the tileset. Next I'll create a large world map, and add the scrolling portions. SHould be able to post again soon.

BTW, I had to edit the image (and I changed the names), the pink didn't save as rgb(255,0,255). I'll swap them out, with the new corrected images.




"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Nov 2008 02:37
i also have code lying around here somewhere for zooming in on a 2D map.


zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 18th Nov 2008 03:13 Edited at: 18th Nov 2008 03:17
Quote: "i also have code lying around here somewhere for zooming in on a 2D map."


I'd be interested in seeing that Phaelax


Just put some what of a Keyboad Input Handler around it.



And Finally now I can get onto the items asked about in the original post. I'll separate those sections out in snippets, and explain them.

"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin
zeddex2
17
Years of Service
User Offline
Joined: 4th Mar 2007
Location:
Posted: 20th Nov 2008 19:38
WoW guy tks a lot ( Sry got some problem with my new job + baby ) I'll check all that stuff right now.

Tks a lot.

If you can, I can!
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 20th Nov 2008 19:46
@zeddex,

I will post the basic scrolling code tonight. Snes Zelda is a bit weird as it combines smooth scrolling, tile scrolling, and has zones where you reach a certain boundaries, it shifts the entire map. So in order to demonstrate this, I needed to create a lareger world map than is usually necessary for demo example.

"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin
zeddex2
17
Years of Service
User Offline
Joined: 4th Mar 2007
Location:
Posted: 21st Nov 2008 00:14
I'm working with phaelax code to learn how to deal with scrolling map.

After that I'll try to learn how you deal with that too.

This is my code at this moment for my speudo zelda game.


As an attachment, all the media needed to run is is there.

I have my charactere walking on a ramdom map and its fine for me now. The only problem I have is when he's moving to the right, when He's supposed to stop, he don't and I have an error on my program becose he exceed my array limit.

I will work now with your way of making the scrolling map.

I found out how to deal with the map, that is nice, next is to find out how to deal with position since you can't really use coord on screen.

If you can, I can!

Attachments

Login to view attachments
zeddex2
17
Years of Service
User Offline
Joined: 4th Mar 2007
Location:
Posted: 21st Nov 2008 01:28
ok in my code I have a problem, when I reach the rigth border of my map my game crash becose I exceed my array limite and I'm not able to resolve my problem.

Now we reach the time of my second question.

How to deal with NPC/Monster with static position on the map (but not on the screen)

I'm thinking of making some type on my array. Ex:

Type mapstuff
Image as integer `the number of the image to be displayed on the tile
sprite as integer `an image to add a sprite over the tile
NPC as integer `the number of the sprite
etc..
endtype

map as mapstuff
dim map(64, 64)


so in my map I will have the image for the tile, the sprite image for the NPC and other stuff ( and information.)

If anyone know if I'm wrong before I'm wasting some houre to make this LOL

tks guy

If you can, I can!
zeddex2
17
Years of Service
User Offline
Joined: 4th Mar 2007
Location:
Posted: 21st Nov 2008 05:04
Ok I'm about to cry tonigh.........


I'm trying for many houre to find out why I can't go to my botom border with the scrolling map.

this is my code:


I have an error at this line

img = Map(mapx+ix, mapy+iy).images

becose somehow mapy+iy is able to reach a number out of my array.

I tryed to use some kind of code like
if mapy+iy > 64
exit
endif

I tryed to use
if mapy+iy <64
mapy = 62
endif

but everytime I debug my game, mapy find a way to reach 560 and make my game crash.


Plz Help me

If you can, I can!
zeddex2
17
Years of Service
User Offline
Joined: 4th Mar 2007
Location:
Posted: 21st Nov 2008 05:33
nvm got it now

If you can, I can!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Nov 2008 17:32
Quote: "How to deal with NPC/Monster with static position on the map (but not on the screen)"


It's actually pretty simple. Keep all your player and monster coordinates stored as real-world coordinates and not grid based. This makes it easier to work with in the long run because it's just like operating with a character on a matrix in 3D.

Suppose you have a map of 500x500 tiles at 32x32 pixels per tile. That's a map with real world coordinates ranging from 0 to 16,000, obviously most of the map is off screen. You can use MapX and MapY to keep track of the map scrolling. This is the offset for the tiles. If its at 1400:758, then the upper left-most tile would be (43,23), which would only partially be visible. Just divide the real-world numbers by the size of the tiles to get the map position in terms of your grid.

So let's say your NPC is sitting on his bum at 2,340:790. If the map offset is still 1400:758, and the total viewable size of the map on screen is only 800x600, then the map currently only shows up to 2200:1358. Your NPC is still beyond the 2200 value so you can ignore drawing it on screen.

My tutorial might be able to give you a little help. I know the code is different than what I have in the codebase, not sure which does what.
http://zimnox.com/dbcc/?page=tutorials

Also, I haven't really looked at your code yet, so ignore me if this is already how you're doing it.


zeddex2
17
Years of Service
User Offline
Joined: 4th Mar 2007
Location:
Posted: 21st Nov 2008 18:21
Basicly what I'm doing right now is:

I'm storing NPC and Sprite in a array of my map.

like this

type Mapstuff
images as integer
Sprte1 as integer
Sprte2 as integer
Sprte3 as integer
Priority as integer
Passable as integer
endtype
Map(X, y) as Mapstuff

and I check in my map drawing if Map(X,Y).Sprite1 >0 and etc.. and draw it on the screen when I have something.

But that way I'm not sure How I can andle the movement of my NPC. but I'm still learning how to deal with that.

I was pretty good with 3d stuff a while ago (I've stop playing with 3d becose my 3d model was really bad and I'm better at 2d)


Now my map have 65 tile x 65 tile and 1 tile = 16x16px

so you mean I can use coord with my tile.

coord betwen 1040x1040

mmmmmm this way look more usefull than my way at this moment. tks Paelax

If you can, I can!

Login to post a reply

Server time is: 2024-05-02 23:18:39
Your offset time is: 2024-05-02 23:18:39