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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - qsik

Pages: [1] 2 3 4
1
Graphics / Draw Missing!?
« on: September 07, 2008, 12:10:36 am »
i know unicode allows for international characters but does turning it off do anything that would majorly affect my program?

otherwise...i could have fixed this a long time ago

2
Graphics / Draw Missing!?
« on: September 04, 2008, 01:18:29 am »
can i use a wstring in sf::LoadImageFromFile()?

3
Graphics / Draw Missing!?
« on: September 01, 2008, 04:28:54 am »
a little help?

4
Graphics / Draw Missing!?
« on: August 29, 2008, 06:00:09 am »
i still cant figure out how to be able to use std::strings in GetModuleFileName() or convert TCHARS to std::strings

also, can someone explain the poor quality of the text in the images of my program (they are really pixelated on my 1024 x 768 screen)

**why does everything on the site seem so much smaller?

5
Graphics / Draw Missing!?
« on: August 23, 2008, 07:13:10 am »
how's this for a first comment attempt?

Code: [Select]
#include "SFML/Quickstart.h"
#include "SFML/String Conversion.h"

int CheckCategories[6];
int CheckMoney[30];

std::string Path;

sf::Sprite Other[6];
sf::Sprite Categories[6];
sf::Sprite Money[30];
sf::Sprite Question;
sf::Sprite Answer;

sf::Image other[6];
sf::Image categories[6];
sf::Image money[5];
sf::Image question;
sf::Image answer;

sf::Music Music[4];

//Function returning the current screen resolution's width
int GetDesktopWidth()
{
sf::VideoMode DesktopMode = sf::VideoMode::GetDesktopMode();
return DesktopMode.Width;
}

//Function returning the current screen resolution's height
int GetDesktopHeight()
{
sf::VideoMode DesktopMode = sf::VideoMode::GetDesktopMode();
return DesktopMode.Height;
}

std::string GetExeD()
{
GetModuleFileName(NULL, L"Path", 100);
return Path;
}

//Load images from subfolders of /Jeopardy
int LoadImages()
{
std::string base = "C:/Jeopardy/";
std::string end = ".bmp";
std::string middle;
std::string image;

for(int i = 0; i < 6; i++)
{
middle = Convert((i + 1));
image = base + "Other/Slide" + middle + end;
if (!other[i].LoadFromFile(image))
return -1;
image = base + "Categories/Slide" + middle + end;
if (!categories[i].LoadFromFile(image))
return -1;
};

for(int i = 0; i < 5; i++)
{
middle = Convert((i + 1));
image = base + "Money/Slide" + middle + end;
if (!money[i].LoadFromFile(image))
return -1;
};

return 1;
}

//Assign all loaded images to sprites
void LoadSprites()
{
for (int i = 0; i < 6; i++)
{
Other[i].SetImage(other[i]);
Categories[i].SetImage(categories[i]);
};

for (int i = 0; i < 5; i++)
{
Money[i].SetImage(money[i]);
Money[(i + 5)].SetImage(money[i]);
Money[(i + 10)].SetImage(money[i]);
Money[(i + 15)].SetImage(money[i]);
Money[(i + 20)].SetImage(money[i]);
Money[(i + 25)].SetImage(money[i]);
};
}

//Scale sprites to have each fit 1/6 of the screen resolution
void ScaleSprites()
{
int ScreenWidth = GetDesktopWidth();
int ScreenHeight = GetDesktopHeight();
float ImageWidth;
float ImageHeight;

for (int i = 0; i < 6; i++)
{
ImageWidth = other[i].GetWidth();
ImageHeight = other[i].GetHeight();
ImageWidth = (ScreenWidth / ImageWidth);
ImageHeight = (ScreenHeight / ImageHeight);
Other[i].Scale(ImageWidth, ImageHeight);

ImageWidth = categories[i].GetWidth();
ImageHeight = categories[i].GetHeight();
ImageWidth = ((ScreenWidth/6) / ImageWidth);
ImageHeight = ((ScreenHeight/6) / ImageHeight);
Categories[i].Scale(ImageWidth, ImageHeight);
};

for (int i = 0; i < 30; i++)
{
ImageWidth = money[0].GetWidth();
ImageHeight = money[0].GetHeight();
ImageWidth = ((ScreenWidth/6) / ImageWidth);
ImageHeight = ((ScreenHeight/6) / ImageHeight);
Money[i].Scale(ImageWidth, ImageHeight);
};
}

//Position sprites evenly across the screen in a 6 x 6 grid
void PositionSprites()
{
int ScreenWidth = GetDesktopWidth();
int ScreenHeight = GetDesktopHeight();
float xpos = (ScreenWidth/6);
float ypos = (ScreenHeight/6);
float x = 0;
float y = ypos;

for(int i = 0; i < 6; i++)
{
Categories[i].SetPosition(x, 0.0f);
x = x + xpos;
};

for(int i = 0; i < 5; i++)
{
Money[i].SetPosition(0, y);
Money[(i + 5)].SetPosition(xpos, y);
Money[(i + 10)].SetPosition((xpos * 2), y);
Money[(i + 15)].SetPosition((xpos * 3), y);
Money[(i + 20)].SetPosition((xpos * 4), y);
Money[(i + 25)].SetPosition((xpos * 5), y);
y = y + ypos;
};
}

//Load music
int LoadMusic()
{
if (!Music[0].OpenFromFile("C:/Jeopardy/Music/Opening.wav"))
return -1;

if (!Music[1].OpenFromFile("C:/Jeopardy/Music/Question.wav"))
return -1;

if (!Music[2].OpenFromFile("C:/Jeopardy/Music/Daily Double.wav"))
return -1;

if (!Music[3].OpenFromFile("C:/Jeopardy/Music/Final Jeopardy.wav"))
return -1;

return 1;
}

//Check to see if sprite has been clicked or not
void InitChecks()
{
for(int i = 0; i < 6; i++)
CheckCategories[i] = 1;
for(int i = 0; i < 30; i++)
CheckMoney[i] = 1;
}

//Execute all the functions above and play the Opening Music
int Load()
{
GetExeD();
LoadImages();
LoadSprites();
ScaleSprites();
PositionSprites();
LoadMusic();
InitChecks();
Music[0].Play();

return 1;
}

6
Graphics / Draw Missing!?
« on: August 21, 2008, 11:57:15 pm »
how descrptive should the comments be? could u give an example

7
Graphics / Draw Missing!?
« on: August 21, 2008, 04:59:42 am »
thnx man, it fixed the errors!

this is correct

Code: [Select]
for (int i = 0; i < 5; i++)
   {
      Money[i].SetImage(money[i]);
      Money[(i + 5)].SetImage(money[i]);
      Money[(i + 10)].SetImage(money[i]);
      Money[(i + 15)].SetImage(money[i]);
      Money[(i + 20)].SetImage(money[i]);
      Money[(i + 25)].SetImage(money[i]);
   };


making 30 images is too slow and costly, so creating 5 sprites of each money image is more efficient and loads quicker

as my small image in a previous post shows, the text in the images are kind of grainy. im scaling 960 x 720 images into (1024/6) x (768/6) images to fit all 36 images on the screen...why do they look kind of bad?

8
Graphics / Draw Missing!?
« on: August 20, 2008, 07:32:56 pm »
!!! WARNING !!! i dont use comments, but instead try to make my code make as much sense as possible through the use of good variable names and sensible function names though some of it may not make sense 'cause im not completely done

String Conversion.h

Code: [Select]
#include <iostream>
#include <sstream>
#include <string>

std::string Convert(int number)
{
std::stringstream converter;
converter << number;
return converter.str();
}


Jeopardy.h

Code: [Select]

#include "SFML/Quickstart.h"
#include "SFML/String Conversion.h"

int ScreenWidth;
int ScreenHeight;

int CheckCategories[6];
int CheckMoney[30];

std::string Path;

sf::Sprite Other[6];
sf::Sprite Categories[6];
sf::Sprite Money[30];
sf::Sprite Question;
sf::Sprite Answer;

sf::Image other[6];
sf::Image categories[6];
sf::Image money[5];
sf::Image question;
sf::Image answer;

sf::Music Music[4];

void GetDesktopMode()
{
sf::VideoMode DesktopMode = sf::VideoMode::GetDesktopMode();
ScreenWidth = DesktopMode.Width;
ScreenHeight = DesktopMode.Height;
}

std::string GetExeD()
{
GetModuleFileName(NULL, L"Path", 100);
return Path;
}

int LoadImages()
{
std::string base = "C:/Jeopardy/";
std::string end = ".bmp";
std::string middle;
std::string image;

for(int i = 0; i < 6; i++)
{
middle = Convert((i + 1));
image = base + "Other/Slide" + middle + end;
if (!other[i].LoadFromFile(image))
return -1;
image = base + "Categories/Slide" + middle + end;
if (!categories[i].LoadFromFile(image))
return -1;
};

for(int i = 0; i < 5; i++)
{
middle = Convert((i + 1));
image = base + "Money/Slide" + middle + end;
if (!money[i].LoadFromFile(image))
return -1;
};

return 1;
}

void LoadSprites()
{
for (int i = 0; i < 6; i++)
{
Other[i].SetImage(other[i]);
Categories[i].SetImage(categories[i]);
};

for (int i = 0; i < 5; i++)
{
Money[i].SetImage(money[i]);
Money[(i + 5)].SetImage(money[i]);
Money[(i + 10)].SetImage(money[i]);
Money[(i + 15)].SetImage(money[i]);
Money[(i + 20)].SetImage(money[i]);
Money[(i + 25)].SetImage(money[i]);
};
}

void ScaleSprites()
{
float ImageWidth;
float ImageHeight;

for (int i = 0; i < 6; i++)
{
ImageWidth = other[i].GetWidth();
ImageHeight = other[i].GetHeight();
ImageWidth = (ScreenWidth / ImageWidth);
ImageHeight = (ScreenHeight / ImageHeight);
Other[i].Scale(ImageWidth, ImageHeight);

ImageWidth = categories[i].GetWidth();
ImageHeight = categories[i].GetHeight();
ImageWidth = ((ScreenWidth/6) / ImageWidth);
ImageHeight = ((ScreenHeight/6) / ImageHeight);
Categories[i].Scale(ImageWidth, ImageHeight);
};

for (int i = 0; i < 30; i++)
{
ImageWidth = money[i].GetWidth();
ImageHeight = money[i].GetHeight();
ImageWidth = ((ScreenWidth/6) / ImageWidth);
ImageHeight = ((ScreenHeight/6) / ImageHeight);
Money[i].Scale(ImageWidth, ImageHeight);
};
}

void PositionSprites()
{
float xpos = (ScreenWidth/6);
float ypos = (ScreenHeight/6);
float x = 0;
float y = ypos;

for(int i = 0; i < 6; i++)
{
Categories[i].SetPosition(x, 0.0f);
x = x + xpos;
};

for(int i = 0; i < 5; i++)
{
Money[i].SetPosition(0, y);
Money[(i + 5)].SetPosition(xpos, y);
Money[(i + 10)].SetPosition((xpos * 2), y);
Money[(i + 15)].SetPosition((xpos * 3), y);
Money[(i + 20)].SetPosition((xpos * 4), y);
Money[(i + 25)].SetPosition((xpos * 5), y);
y = y + ypos;
};
}

int LoadMusic()
{
if (!Music[0].OpenFromFile("C:/Jeopardy/Music/Opening.wav"))
return -1;

if (!Music[1].OpenFromFile("C:/Jeopardy/Music/Question.wav"))
return -1;

if (!Music[2].OpenFromFile("C:/Jeopardy/Music/Daily Double.wav"))
return -1;

if (!Music[3].OpenFromFile("C:/Jeopardy/Music/Final Jeopardy.wav"))
return -1;

return 1;
}

void InitChecks()
{
for(int i = 0; i < 6; i++)
CheckCategories[i] = 1;
for(int i = 0; i < 30; i++)
CheckMoney[i] = 1;
}

int Load()
{
GetExeD();
GetDesktopMode();
LoadImages();
LoadSprites();
ScaleSprites();
PositionSprites();
LoadMusic();
InitChecks();
Music[0].Play();

return 1;
}


Main.cpp

Code: [Select]
#include "Jeopardy.h"

int main()
{
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Jeopardy!");
Load();
int stage = 1;

while(App.IsOpened())
    {
sf::Event Event;

while (App.GetEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
if ((Event.Type == sf::Event::MouseButtonPressed) && (Event.MouseButton.Button == sf::Mouse::Left) && (stage < 3))
stage = stage + 1;
};

App.Clear(sf::Color(17, 86, 178));
if (stage == 1)
App.Draw(Other[0]);
if (stage == 2)
App.Draw(Other[1]);
if (stage == 3)
{
for(int i = 0; i < 6; i++)
{
if(CheckCategories[i] == 1)
App.Draw(Categories[i]);
};

for(int i = 0; i < 30; i++)
{
if(CheckMoney[i] == 1)
App.Draw(Money[i]);
};
};

App.Display();
    };

return EXIT_SUCCESS;
}

9
Graphics / Draw Missing!?
« on: August 20, 2008, 04:32:38 pm »
*bump

--still cant figure it out

10
Graphics / Draw Missing!?
« on: August 18, 2008, 07:41:28 pm »
sorry, i changed the size of Money[] to 30 to hold the needed 30 images unless there is a way to duplicate sprites w/o having to create more sprite variables

11
Graphics / Draw Missing!?
« on: August 18, 2008, 05:31:43 am »
*bump

a little help?

12
Graphics / Draw Missing!?
« on: August 15, 2008, 10:19:07 pm »
im making progress, but a problem has popped up. i was using the debugger and my array for my "money" sprites has all the sprites loaded, their positions set, and the loop has the correct numbers to draw...but only the first row appears? here's my code, i cant seem to find the problem

Code: [Select]
for (int i = 0; i < 5; i++)
{
Money[i].SetImage(money[i]);
Money[(i + 5)].SetImage(money[i]);
Money[(i + 10)].SetImage(money[i]);
Money[(i + 15)].SetImage(money[i]);
Money[(i + 20)].SetImage(money[i]);
Money[(i + 25)].SetImage(money[i]);
};


Code: [Select]
void PositionSprites()
{
float xpos = (ScreenWidth/6);
float ypos = (ScreenHeight/6);
float x = 0;
float y = ypos;

for(int i = 0; i < 6; i++)
{
Categories[i].SetPosition(x, 0.0f);
x = x + xpos;
};

for(int i = 0; i < 5; i++)
{
Money[i].SetPosition(0, y);
Money[(i + 5)].SetPosition(xpos, y);
Money[(i + 10)].SetPosition((xpos * 2), y);
Money[(i + 15)].SetPosition((xpos * 3), y);
Money[(i + 20)].SetPosition((xpos * 4), y);
Money[(i + 25)].SetPosition((xpos * 5), y);
y = y + ypos;
};
}


Code: [Select]
for(int i = 0; i < 30; i++)
{
if(CheckMoney[i] == 1)
App.Draw(Money[i]);
};



13
Graphics / Draw Missing!?
« on: August 14, 2008, 06:50:21 am »
i switched to bmps cause the pngs werent working...but now the image sizes are much bigger :( (the pngs are exported from powerpoint slides --> a problem?)

--is there a way to get rid of sf::clock? i want to implement a timer so that SFML shows a "loading screen" while loading images in the background, but dont want the sf::clock to continually run and waste resources (im targetting older hardware so i need to save as much space as i can)

**still need help with GetModuleFileNameExW

14
Graphics / Draw Missing!?
« on: August 14, 2008, 01:00:47 am »
this is strange, the loop goes through 3 times and then on the 4th loop, questions[4] cant seem to load C:/Jeopardy/Questions/Slide5.png (but the image load fine in GIMP and so the loop breaks (does lack of memory also cause images to not load?)

--using GetModuleFileNameExW i get an identifier not found?

15
Graphics / Draw Missing!?
« on: August 13, 2008, 09:29:37 pm »
very odd, this for loop breaks out after 5 iterations...even though it should run 30 times right?
Code: [Select]

int LoadImages3()
{
for(int i = 0; i < 30; i++)
{
middle = Convert((i + 1));
image = base + "Questions/Slide" + middle + end;
if (!questions[i].LoadFromFile(image))
return -1;
image = base + "Answers/Slide" + middle + end;
if (!answers[i].LoadFromFile(image))
return -1;
};

return 1;
}

Pages: [1] 2 3 4