• Post Reply Bookmark Topic Watch Topic
  • New Topic

2d Scrolling

 
Dustin Yourstone
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all. Ive been working on a project that involves a top down scrolling envorioment. My current code creates an image by drawing the whole world, then draws the complete image to the screen based on the offset. This is very slow, so I was wondering if there were any suggestions to make it faster. Also is there any methods to crop images? thx
EagleEye101
 
John Dove
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Possibly lower your frame rate? (I believe I read somewhere that 18-25 frames a second is good - anything higher could cause un-needed lag). Also, use a smaller "viewport" into your game's coordinate system; i.e. the "entire image" that is continually needing to be redrawn will therefore be smaller and quicker to render.

-jdove
 
HaoZhe Xu
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure about your situation, but I can tell you the situation I met:

it's a 2D role-play game, the tile-based map has 5 layers:
tile
cover
flag - whether or not a grid can be walked across
goods
characters and npcs
the strategy I used is: create a buffer (same size as the screen) image at the beginning, each time the screen need to be refreshed, draw the 5 layers in order to the buffer and then draw the buffer to screen, it looks smooth.

the idea for your game is: can you break the whole world map into several grids so duplicate grids can be avoided, is your world image too large so the speed is low? then you can break the whole image into several smaller parts and use extra data to represent the edge of each image part, when you are achieving an edge, just concurrently load the next part, if the next part has not been loaded yet when it should be displayed, then you have to stop for a while and wait, but this does not usually happen - if it doesn't happen at all, then displaying small image should be smoother ;-)

Sincerely
Olnex
 
tito bayuadji
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
create OffImage (buffer) perhaps it will make it faster somehow.
but it just a wild guest.
 
Jean-Sebastien Abella
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey!
If you are drawing the whole world that's why it has poor refresh rate...
what you wannna check before drawing anything is if it visible. Then you will save a lot of cpu cycle!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!