Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Image cache for a basic game  (Read 2048 times)

0 Members and 1 Guest are viewing this topic.

URSvAir14

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image cache for a basic game
« on: February 28, 2014, 06:19:02 pm »
Hello All!

I already understand what a cache is, but I have a question about using one in my game. Firstly, what would be the best way to implement a cache using SFML and c++? I assume I'd need to make a collection of global textures that could be accessed from anywhere, but how should I do it?
Secondly, what kind of things should I load into the cache and what shouldn't I load? I think that I should load in the texture containing my common enemies and the texture containing different projectiles, but what other things should I be using there?

Thank you!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Image cache for a basic game
« Reply #1 on: February 28, 2014, 06:31:31 pm »
Firstly, what would be the best way to implement a cache using SFML and c++?
Don't reinvent the wheel. My library Thor already offers a resource-managing module, and there's a simpler more lightweight version (ResourceHolder) in the SFML book.

I assume I'd need to make a collection of global textures that could be accessed from anywhere
No. Global is mostly bad, and always in the case of SFML resource objects. You should rather think about a clean design that allows you to access textures from the places where you need them -- not from everywhere.

Secondly, what kind of things should I load into the cache and what shouldn't I load? I think that I should load in the texture containing my common enemies and the texture containing different projectiles, but what other things should I be using there?
When you already have a cache, why not load everything with it? At least the one from Thor is smart enough to recognize when you're attempting to load duplicates.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

URSvAir14

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Image cache for a basic game
« Reply #2 on: February 28, 2014, 06:34:22 pm »
Okay, thanks :D

 

anything