• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

2d Scrolling

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
create OffImage (buffer) perhaps it will make it faster somehow.
but it just a wild guest.
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
We've gotta get close enough to that helmet to pull the choke on it's engine and flood his mind! Or, we could just read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic