Skip to main content
gamedev.net
🔒 Locked

Question about performance, again...

Started by Ilankt 4 replies 450+ views
Original Post
Ilankt
Ilankt
well, i''m making an Tile Based Game, and let''s say that i have a BIG map, something like 100*100, this is 10,000 Tiles to draw at the same time, and this cause my computer to slow down, and this is only to draw the tiles... is there any other way to draw only one part of the map in a time, because how i''m doing now, i draw all the map, in each frame, and this is REALLY SLOW...
How appropriate, you fight like a cow!
JY
JY
Yip - only draw those parts of the map that will be visible at any one time.

Think of your display area as a ''window'' on the map - work out which tiles will be visible and only draw those. How this happens depends on the layout of your map. Post more information for more help.....
"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan
Dominik_78
Dominik_78
Hi,

i am making a tile game too.
i just got a array of my map tiles.
depending on the players position in the world (i recognice a x/y where my char is) i draw all tiles that are "right" "infront" "left" and "behind" the player that is "n" tiles away - the "n" depends on the resultion. that is fast enough.
and keep the bounds of the map in mind - so if the player is at 0/0 just draw all from 0/0 to n/n.
do it end up with

player x/y

draw all tiles from x-n/y-n to x+n/y+n

good luck

[edited by - Dominik_78 on July 18, 2003 11:43:42 AM]
Alexis Magoog
Alexis Magoog
A good way also is to use a Mousemaproutine and use the coords: 0-0, 640-0, 0-480 and 640-480 (or what resolution you use), these are are the corners of the screen...
now you get foure map-coordinates and you know the first row and the last row (also left and right)... and now you can use a tilewalker-routine to go through the lines...

to make a fine tuning just use two or three lines in every direction more so you don''t have black "error" fileds...

just have a look at the isohex engine


--Alexis Magoog
--Alexis Magoog
Ilankt
Ilankt
ok, thanks, i will try to work on what tiles i should display.
How appropriate, you fight like a cow!
JNewt
JNewt
It''s pretty simple, especially if it''s a square tile based game.

First you need two variables that store what tile the top left corner of the screen has been scrolled to, ViewX, ViewY.

Then, in your render loop:

For X=0 to ScreenWidth
For Y=0 to ScreenHeight
DrawTile MAP(X+ViewX, Y+ViewY), X, Y
Next Y
Next X


Customize this to work with your language and drawing procedures.
7|-|3 p057 @b0v3 i5 c3/^7i|=i3|) 1337!100|< |=0/^ j||3|/|7

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.