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 - Bonafide

Pages: [1] 2
1
General / Proper way of creating a "release" copy of my proj
« on: May 01, 2009, 01:32:48 am »
Hey guys,

After months of coding, my group is finally done with our game for our class project - a simple side scrolling platform, with our teacher as the main character! Anyway, I wa wondering if there is a "proper" way of creating a release build.

I have included the release libs in the additional dependencies field in Linker's options, and compiled the project in release mode. However, it only creates the .exe and a few system files (which I'm not sure what they do). I pasted all the necessary files in the release folder, and the .exe does run properly, however, the nasty console window pops up with every run. Where's the option to get rid of it?

Thanks,
Bonafide

2
Graphics / Repeating background?
« on: March 25, 2009, 06:16:39 pm »
Hey guys,

I'm wondering if there is a simple way of redrawing a background once it begins to run out of the View rectangle, or if it was possible to set an image as the background of a window/screen.

One more question. What's the method to check if there is a mouse click on a certain part of an image (e.g. a title screen, and I want to click on play or options, etc.)?

3
General / 1st Demo Using SFML - Only Get Console Window - HELP
« on: March 09, 2009, 07:23:39 pm »
Thanks, it's working now.

The problem was that I forgot to change the array dimensions to the results of 1600/32 and 640/32, which is 50 and 20 respectively.

4
General / 1st Demo Using SFML - Only Get Console Window - HELP
« on: March 09, 2009, 04:17:05 am »
Hey guys, I'm having a similar problem, but different (not the joystick issue). The difference is that my code will not run UNLESS I omit a few lines of code from it, and I don't see why those few lines would be a problem to the program. I've ran the same code in other instances (drafts, etc) and it has ran without problem.

I know there are two areas within the code that draws santa and the block twice, that isn't the problem, I've changed it around when trying to run the program - to no avail.

Here's the problematic code:
Code: [Select]

#include <SFML/Graphics.hpp>
#include <iostream>
#include <fstream>
#include "Collision.h"
#include "Map.h"

using namespace std;
using namespace sf;


int main()
{
//Load collision
Collision coll;  

// Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Window");

    // Load the sprite image from a file
    sf::Image imgBlock;
    if (!imgBlock.LoadFromFile("blocks.jpg"))
        return EXIT_FAILURE;

sf::Image imgSanta;
if (!imgSanta.LoadFromFile("santa.png"))
        return EXIT_FAILURE;

    // Create the sprite
    sf::Sprite block(imgBlock);
sf::Sprite santa(imgSanta);

    // 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();
        }

        // Get elapsed time
        float ElapsedTime = App.GetFrameTime();

/*///////////////////////////////////////////////
//Declare map & level variables
MAP map;

char level[1600][640];

//Open file stream;
ifstream file;

//Load
map.mapLoad(file, level);

//num holder
int num;

//Display
for(int y = 0; y < 1600; y++)
{
for(int x = 0; x < 640; x++)
{
num = level[y][x];

if(num == '1')
{
  block.SetPosition(x*32, y*32);
  App.Draw(block);
}
if(num == '2')
{
App.Draw(santa);
}
}
}
////////////////////////////////// */

if (App.GetInput().IsKeyDown(sf::Key::Left))
{
if(coll.detectCollision(santa, block) != true)
{
santa.Move(-100 * ElapsedTime, 0);
}
else
{
santa.SetPosition((santa.GetPosition().x + 3), (santa.GetPosition().y));
}
}
if (App.GetInput().IsKeyDown(sf::Key::Right))
{
if(coll.detectCollision(santa, block) != true)
{
santa.Move(+100 * ElapsedTime, 0);
}
else
{
santa.SetPosition((santa.GetPosition().x - 3), (santa.GetPosition().y));
}
}
if (App.GetInput().IsKeyDown(sf::Key::Up))
{
if(coll.detectCollision(santa, block) != true)
{
santa.Move(0, -100 * ElapsedTime);
}
else
{
santa.SetPosition((santa.GetPosition().x), (santa.GetPosition().y) + 3);
}
}
if (App.GetInput().IsKeyDown(sf::Key::Down))
{
if(coll.detectCollision(santa, block) != true)
{
santa.Move(0,  100 * ElapsedTime);
}
else
{
santa.SetPosition((santa.GetPosition().x), (santa.GetPosition().y) - 3);
}
}

        // Rotate the sprite
        if (App.GetInput().IsKeyDown(sf::Key::A)) santa.Rotate(- 100 * ElapsedTime);
        if (App.GetInput().IsKeyDown(sf::Key::D)) santa.Rotate(+ 100 * ElapsedTime);

        // Clear screen
        App.Clear();

        // Display sprite in our window
        App.Draw(santa);
App.Draw(block);

        // Display window contents on screen
        App.Display();
    }
    return EXIT_SUCCESS;
}


Here's the code that won't make the program run unless omitted (its in the code above):
Code: [Select]

/*///////////////////////////////////////////////
//Declare map & level variables
MAP map;

char level[1600][640];

//Open file stream;
ifstream file;

//Load
map.mapLoad(file, level);

//num holder
int num;

//Display
for(int y = 0; y < 1600; y++)
{
for(int x = 0; x < 640; x++)
{
num = level[y][x];

if(num == '1')
{
  block.SetPosition(x*32, y*32);
  App.Draw(block);
}
if(num == '2')
{
App.Draw(santa);
}
}
}
////////////////////////////////// */


Map class, if that's the issue:
Code: [Select]

#include <SFML/Graphics.hpp>  
#include <SFML/System.hpp>
#include <iostream>
#include <fstream>

using namespace sf;
using namespace std;

#define HEIGHT 1600;
#define WIDTH 600;



class MAP
{
public:
void mapLoad(ifstream& file, char level[1600][640]);

};

void MAP::mapLoad(ifstream &file, char level[1600][640])
{
//Input map file
file.open("level.txt");

//Holds the information line by line
std::string line;

//Height of the file
int fileHeight = 0;

while(std::getline(file, line))
{
for(int fileWidth = 0; fileWidth < 10; fileWidth++)
{    
  level[fileHeight][fileWidth] = line.at(fileWidth);
}    
fileHeight++;
}

//Close file stream
file.close();
}


All help is appreciated!

5
General / Rect.Intersect() - Driving me mad
« on: March 08, 2009, 11:00:03 pm »
EDIT: Nevermind, this problem has been resolved.


Bump.

hey guys, I've seem to hit another road bump. Collision is now working, and I have made it so that if the blocks do collide, my moving block will move back a few units from the stationary block. However, if I hold a movement button (say the left key for this example) and make the block "stutter/jitter" (the block wants to continue moving left, but keeps getting pushed back a few units), if I press another movement key at the right time, the moving block will slide across the stationary block on it's corresponding side. I know it's my method of getting the blocks unstuck, so any tips would be appreciated.

Here's essentially what I have:
Code: [Select]

if (App.GetInput().IsKeyDown(sf::Key::Left))
{
if(coll.detectCollision(Sprite, Spr) != true)
{
Sprite.Move(-100 * ElapsedTime, 0);
}
else
{
Sprite.SetPosition((Sprite.GetPosition().x + 3), (Sprite.GetPosition().y));
}
}

6
General / Rect.Intersect() - Driving me mad
« on: March 06, 2009, 11:08:46 am »
Heh, I did not catch that, but it finally works, thank you!

7
General / Rect.Intersect() - Driving me mad
« on: March 05, 2009, 08:21:59 pm »
Hey guys,

I've tried searching the forums for a solution, and I've found some helpful threads that have given me some clues as how the Intersect() function works, but I just can't get it to work.

I'm simply trying to get a block to stop moving when it collides with another, stationary block.

Here's the code:
Code: [Select]

float left1, left2, right1, right2, top1, top2, bottom1, bottom2;

left1 = Sprite.GetPosition().x;
left2 = Spr.GetPosition().x;
right1 = left1 - Sprite.GetSize().x;
right2 = left2 - Spr.GetSize().x;
top1 = Sprite.GetPosition().y;
top2 = Spr.GetPosition().y;
bottom1 = top1 + Sprite.GetSize().y;
bottom2 = top2 + Sprite.GetSize().y;

sf::FloatRect Rect(left1, top1, right1, bottom1);
sf::FloatRect Rect2(left2, top2, right2, bottom2);

        // Get elapsed time
        float ElapsedTime = App.GetFrameTime();

        // Move the sprite
if(Rect.Intersects(Rect2))
{
cout << 1;
}
else
{
                        // Key
                }


The collision of the two sprites just won't work, Sprite just runs through Spr.

8
General / Unicode errors with VS C++ 6 (aka VS98).
« on: March 05, 2009, 07:28:24 pm »
Quote from: "Astrof"
Quote from: "Bonafide"
Thanks for the help Laurent, but I can't seem to find such an option. Google hasn't been much of a help either, I guess I may have to make the switch to SDL  :x .


couldn't you "switch" to a newer version of Visual Studio? (The express editions are free).  Or use Code::Blocks? VS98 is over a decade old...


Trust me, I'd love to upgrade to VS2008 Express, but as I said, we're trying to run the library on school computers. We don't have computer prviledges to install programs on the computers, we'd have to go through the IT Dept. of the school (which they won't approve of), and in any case the Express versions cannot be installed on the school computers due to the EULA issues (as told to me by our school IT guy).

We're going to stick with SFML, but we're telling the two guys in our group who were planning on doing all the work on the school computers to work on it at home. The fourth partner and I have been diligently learning SFML and a switch would hinder our progress, and considering it's technically due Monday of next week.

9
General / Unicode errors with VS C++ 6 (aka VS98).
« on: March 05, 2009, 03:02:37 pm »
Thanks for the help Laurent, but I can't seem to find such an option. Google hasn't been much of a help either, I guess I may have to make the switch to SDL  :x .

10
SFML projects / Aphid (Scrolling shooter)
« on: March 04, 2009, 03:23:35 am »
Wow! That's amazing stuff!

11
General / Unicode errors with VS C++ 6 (aka VS98).
« on: March 04, 2009, 02:51:28 am »
Quote from: "Laurent"
Hmm, maybe it's just a matter of setting up your project. In particular, you may have an option like "treat wchar_t as a built-in type" which could solve the problem if checked.


Where is this option found? Project settings?

12
General / Unicode errors with VS C++ 6 (aka VS98).
« on: March 03, 2009, 08:29:47 pm »
Hey guys,

My group for my HS group project is having some strange errors attempting to run SFML (specically the "Clock" tutorial under the installation page) on the the crappy school computers which are running VS 6++ (VS98). For some reason, we're getting the following errors:

Code: [Select]

--------------------Configuration: GroupP - Win32 Debug--------------------
Compiling...
Test.cpp
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(82) : error C2535: '__thiscall sf::Unicode::Text::sf::Unicode::Text(const unsigned short *)' : member function already defined or declared
        c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(80) : see declaration of 'Text::Text'
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(86) : error C2629: unexpected 'class sf::Unicode::Text ('
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(86) : error C2238: unexpected token(s) preceding ';'
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(87) : error C2629: unexpected 'class sf::Unicode::Text ('
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(87) : error C2238: unexpected token(s) preceding ';'
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(88) : error C2629: unexpected 'class sf::Unicode::Text ('
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(88) : error C2238: unexpected token(s) preceding ';'
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(98) : error C2027: use of undefined type 'Unicode'
        c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(45) : see declaration of 'Unicode'
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(99) : error C2027: use of undefined type 'Unicode'
        c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(45) : see declaration of 'Unicode'
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(99) : error C2535: '__thiscall sf::Unicode::Text::operator`class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned sho
rt> >'(void) const' : member function already defined or declared
        c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(97) : see declaration of 'operator`class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >''
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(100) : error C2027: use of undefined type 'Unicode'
        c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(45) : see declaration of 'Unicode'
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(107) : error C2027: use of undefined type 'Unicode'
        c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(45) : see declaration of 'Unicode'
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(241) : error C2039: 'size_t' : is not a member of 'std'
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(253) : error C2039: 'size_t' : is not a member of 'std'
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.hpp(265) : error C2039: 'size_t' : is not a member of 'std'
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.inl(422) : error C2039: 'size_t' : is not a member of 'std'
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.inl(442) : error C2039: 'size_t' : is not a member of 'std'
c:\program files\microsoft visual studio\vc98\include\sfml\system\unicode.inl(471) : error C2039: 'size_t' : is not a member of 'std'
Error executing cl.exe.

GroupP.exe - 18 error(s), 0 warning(s)


Any reason as to why this is happening? I've changed the _MBCS preprocessor definition to _UNICODE, which hasn't helped. I'm not even sure if that was a solution, but gave it a shot.

All help is appreciated! Thanks,
Bonafide

Here is the code:
Code: [Select]

#include <SFML/System.hpp>
#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        cout << Clock.GetElapsedTime() << endl;
        sf::Sleep(0.5f);
    }

    return 0;
}

13
Graphics / Problems with .Draw
« on: February 08, 2009, 09:34:08 pm »
Bah, never thought of setting it to "if equal '0' and '1'," which turned out to be the problem.

Thanks for the help!

14
Graphics / Problems with .Draw
« on: February 08, 2009, 06:36:35 pm »
Here's the full code, sorry if it's a bit messy:

Code: [Select]

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include <fstream>

using namespace sf;
using namespace std;


int main()
{
///////////////////////////////BEGIN LOAD FUNCTION///////////////////////////////////

//Read *filename
//Char array "LEVEL" that will store the integers of file
char level[10][10];

//Read textfle (2D char array made up of a series of integers/letters)
ifstream file("level.txt");

//Store the array into a "temp holder" called tileNum
std::string line;

int height = 0;

while(std::getline(file, line))
{

for(int width = 0; width < 10; width++)
{
level[height][width] = line.at(width);
}
height++;
}

//Close file stream
file.close();

for(int y = 0; y < 10; y++)
{
for(int x = 0; x < 10; x++)
{
cout << level[y][x];
}
cout << endl;
}


/////////////////////////////END LOAD FUNCTION//////////////////////////////////////
///*
/////////////////////////////BEGIN DISPLAY FUNCION//////////////////////////////////

//Display using SFML
//Render Window
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "The CodeWarrior");

//Create image
sf::Image blockImage;
sf::Image groundImage;

if(!blockImage.LoadFromFile("blocks.jpg"))
{
return EXIT_FAILURE;
}

if(!groundImage.LoadFromFile("ground.jpg"))
{
return EXIT_FAILURE;
}

//Create Sprite
sf::Sprite blockTile(blockImage);
sf::Sprite groundTile(groundImage);

//Game loop
while (App.IsOpened())
{
sf::Event Event;
while(App.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed)
{
App.Close();
}
}

//Clear window
App.Clear();

int num;

//Scroll through level and display corresponding image of tile
for(int y = 0; y < 10; y++)
{
for(int x = 0; x < 10; x++)
{
cout << level[y][x] << "LEVEL"; //Test to see what level[y][x] is outputting
cout << endl;
num = level[y][x];
cout << "LOL" << num << "LOL"; // Test to see what num is outputting
cout << endl;

if(num == 48)
{
blockTile.SetPosition(x*32, y*32);
App.Draw(blockTile);
}
else if(num == 49)
{
groundTile.SetPosition(x*32, y*32);
App.Draw(groundTile);
}
}
}


//Display sprites
App.Display();
}
return EXIT_SUCCESS;
//*/
}

15
Graphics / Problems with .Draw
« on: February 08, 2009, 05:12:45 am »
Hey guys,

I'm having a bit of trouble with a bit of code:

Code: [Select]

//Scroll through level and display corresponding image of til
for(int y = 0; y < 10; y++)
{
for(int x = 0; x < 10; x++)
{
cout << level[y][x];
if(level[y][x] == 0)
{
blockTile.SetPosition(x*32, y*32);
App.Draw(blockTile);
}
else if(level[y][x] == 1)
{
groundTile.SetPosition(x*32, y*32);
App.Draw(groundTile);
}


The problem? It won't display any tiles. I have made a checker outside of the for loop to see if level[y]
  • was indeed outputing 0's and 1's (and it was), and if I check inside the posted for-loop, [y]
  • does equal 0 or 1, so I don't have a clue why the argument "if level[y]
  • == 0 or 1" is not working! if I have "num = level[y]
  • ," cout << num outputs a 48 or 49.


If I were to comment the if/else arguments out (shown below), it works perfectly!

Code: [Select]

//Scroll through level and display corresponding image of til
for(int y = 0; y < 10; y++)
{
for(int x = 0; x < 10; x++)
{
cout << level[y][x];
//if(level[y][x] == 0)
//{
blockTile.SetPosition(x*32, y*32);
App.Draw(blockTile);
//}
//else if(level[y][x] == 1)
//{
groundTile.SetPosition(x*32, y*32);
App.Draw(groundTile);
//}
}
}


What could be causing the if arguments to not work?

Edit:
If I change the argument for block tiles to "if num equals 48," it works. If I change the argument for  ground tiles to "if num equals 49," it works. What's going on here?

Pages: [1] 2
anything