1
Graphics / Running Heavy Graphics
« on: September 28, 2011, 07:01:34 pm »
Here's the code:
(the two tiles are 32x32 png images)
Just a question, how would I go about using only one sprite per cell?
(the two tiles are 32x32 png images)
Code: [Select]
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML\System.hpp>
#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(800, 600, 8), "A-Mazing Game");
float movespeed = (32.0f);
sf::Image T1;
if (!T1.LoadFromFile("grass (2).png"))
return EXIT_FAILURE;
T1.SetSmooth(false);
sf::Image T2;
if (!T2.LoadFromFile("water.png"))
return EXIT_FAILURE;
T2.SetSmooth(false);
// Create the sprite
//sf::Sprite Sprite(Image);
sf::Sprite Tile1(T1);
sf::Sprite Tile2(T2);
int map[25][19]= {0};
map[24][0]= 1;
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
App.Clear();
int px = 0;
int py = 0;
for (float qq = 0; qq <= 800; qq +=32)
{
for (float ii = 0; ii <= 608; ii += 32)
{
if (map[px][py] == 0)
{
App.Draw(Tile1);
Tile1.SetPosition(qq,ii);
}
if (map[px][py] == 1)
{
App.Draw(Tile2);
Tile2.SetPosition(qq,ii);
}
py++;
}
px++;
py=0;
}
// Clear screen
// Display sprite in our window
// Display window contents on screen
App.Display();
}
return EXIT_SUCCESS;
}
Just a question, how would I go about using only one sprite per cell?