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.


Topics - JeZ-l-Lee

Pages: 1 2 [3]
31
General / Need an official SFML logo to place in my game...
« on: February 04, 2009, 05:47:08 pm »
Need an official SFML logo to place in my game...

Send to my email address:
SLNTHERO@aol.com

I do this in all of my games.
I put logo and web site at beginning of the library I am using.

Thanks....

32
General / sf::Image Image;// How I delete after use ???
« on: February 04, 2009, 05:28:17 pm »
sf::Image Image;// How I delete after use ???

Hi Again,

Killer game engine library!
Well here is part of my source, please look and help me !

Code: [Select]
sf::Image Image;

if (!Image.LoadFromFile("cute_image2.bmp"))
return EXIT_FAILURE;

Image.CreateMaskFromColor(sf::Color(0, 255, 0, 255), 0);

#define NumberOfSprites 400
sf::Sprite Sprites[NumberOfSprites];
for (uint16_t index = 0; index < NumberOfSprites; index++)
Sprites[index].SetImage(Image);

// delete Image;//  <- compiler ERROR, why? How do I delete Image???

33
General / sf::RenderWindow App - Call it from a C++ Class?
« on: February 04, 2009, 02:44:08 pm »
Hi,

How would I call:
"sf::RenderWindow App" from within a C++ class structure ?

I declare in the header:
sf::RenderWindow App;

And have this in the Class constructor:
sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");

It builds ok, but crashes on Window creation???


Here is the source:

Class Header File:
Code: [Select]
// Visuals header File...

#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>

class Visuals
{
public:

Visuals(void);
virtual ~Visuals(void);

sf::RenderWindow App;

sf::Font Arial;

int LoadFontsIntoMemory(void);
void UnloadFontsFromMemory(void);

void DrawTextOnScreenBuffer(char text[256]);
};


Class C++ File:
Code: [Select]
// Visuals C++ File...

#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>

#include "Visuals.h"

//----------------------------------------------------------------------------------------------------------
Visuals::Visuals(void)
{
sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");
}
//----------------------------------------------------------------------------------------------------------
Visuals::~Visuals(void)
{

}
//----------------------------------------------------------------------------------------------------------
int Visuals::LoadFontsIntoMemory(void)
{
if (!Arial.LoadFromFile("arial.ttf"))
return EXIT_FAILURE;

return EXIT_SUCCESS;
}
//----------------------------------------------------------------------------------------------------------
void Visuals::UnloadFontsFromMemory(void)
{
delete &Arial;
}
//----------------------------------------------------------------------------------------------------------
void Visuals::DrawTextOnScreenBuffer(char text[256])
{
sf::String Text2(text, Arial, 50);
App.Draw(Text2);
delete &Text2;
}
//----------------------------------------------------------------------------------------------------------


main.cpp file
Code: [Select]
// SFML PerfecT+EnginE Version 5.0 GT

#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>

#include "Visuals.h"

Visuals *visuals;

int main()
{
visuals = new Visuals();

// sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");



// Load a sprite to display
sf::Image Image;

if (!Image.LoadFromFile("cute_image2.bmp"))
return EXIT_FAILURE;

Image.CreateMaskFromColor(sf::Color(0, 255, 0, 255), 0);

#define NumberOfSprites 400
sf::Sprite Sprites[NumberOfSprites];
for (uint16_t index = 0; index < NumberOfSprites; index++)
Sprites[index].SetImage(Image);
/*
// Create a graphical string to display
sf::Font Arial;
if (!Arial.LoadFromFile("arial.ttf"))
return EXIT_FAILURE;
sf::String Text("Hello SFML", Arial, 50);
*/
// Load a music to play
sf::Music Music;
if (!Music.OpenFromFile("nice_music.ogg"))
return EXIT_FAILURE;

// Play the music
Music.Play();

// Globals to be moves later:
sf::Clock MyClock;
float MilliSeconds;
float NextFrameMS;
float NextSecond = MyClock.GetElapsedTime() + 1;
uint16_t FramesPerSecond = 0;
uint16_t FPS_Array[10];
for (uint8_t index = 0; index < 10; index++)  FPS_Array[index] = 0;
uint16_t FPS_ArrayIndex = 0;

char VariableText[256];

float SpriteRotation = 0;

// For testing graphic engine speed:
for (uint16_t index = 0; index < NumberOfSprites; index++)
{
Sprites[index].SetX(sf::Randomizer::Random(0.f, 640.f));
Sprites[index].SetY(sf::Randomizer::Random(0.f, 640.f));
}

if (!visuals->LoadFontsIntoMemory())
return EXIT_FAILURE;
//===============================================================================================
// Start the game loop
while (visuals->App.IsOpened())
{
MilliSeconds = MyClock.GetElapsedTime();
NextFrameMS  = MilliSeconds + .01667;

FramesPerSecond++;

if (MilliSeconds >= NextSecond)
{
FPS_Array[FPS_ArrayIndex] = FramesPerSecond;

FramesPerSecond = 0;
NextSecond = MyClock.GetElapsedTime() + 1;

FPS_ArrayIndex++;
if (FPS_ArrayIndex > 9)  FPS_ArrayIndex = 0;
}

// Process events
sf::Event Event;
while (visuals->App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
visuals->App.Close();
}

// Clear screen
visuals->App.Clear();

SpriteRotation++;
if (SpriteRotation > 359)  SpriteRotation = 0;

//Testing...
for (uint16_t index = 0; index < NumberOfSprites; index++)
{
Sprites[index].SetCenter(Sprites[index].GetSize().x / 2, Sprites[index].GetSize().y / 2);
Sprites[index].SetRotation(SpriteRotation);
// Draw the sprite
visuals->App.Draw(Sprites[index]);
}

uint16_t total = 0;
for (uint16_t index = 0; index < 10; index++)
{
total = total + FPS_Array[index];
}
total = total / 10;
sprintf(VariableText, "%d", total);
sf::String Text(VariableText, visuals->Arial, 50);
// visuals->DrawTextOnScreenBuffer("Hi there :)");

// Update the window
visuals->App.Display();

MilliSeconds = MyClock.GetElapsedTime();
if (NextFrameMS > MilliSeconds) sf::Sleep(NextFrameMS - MilliSeconds);
}
//===============================================================================================

visuals->UnloadFontsFromMemory();

delete visuals;

return EXIT_SUCCESS;
}
// A 100% By JeZ+Lee and mattmatteh!



Thanks in advance!!!


JeZ+Lee
SLNTHERO@aol.com
Silent Hero Productions(R)
Video Game Design Studio
http://www.SilentHeroProductions.com

34
General / Is There A Work-Around For Big Joystick BUG ?
« on: February 03, 2009, 11:42:46 pm »
Is There A Work-Around For Big Joystick BUG ?


Hi,

Killer library!
Migrating from SDL to SFML now,
developing a new 2-d game engine.

Made a demo,
but on Windows and USB joystick plugged in,
the demo wont run.

SFML locks when a USB joystick in plugged in.
Is there a work-around for this (besides unpluging joystick)??


Thanks


JeZ+Lee
SLNTHERO@aol.com
Silent Hero Productions(R)
Video Game Design Studio
http://www.SilentHeroProductions.com

35
General / Question about DLLs on Windows Platform...
« on: February 03, 2009, 11:21:04 pm »
Hi,

Are
"sfml-graphics.dll"
&
"sfml-graphics-d.dll"
both needed in the EXE binaries folder on Windows platform ?

What is difference between two above DLLs ?

Thanks, great library so far!!!


JeZ+Lee
SLNTHERO@aol.com
Silent Hero Productions(R)
Video Game Design Studio
http://www.SilentHeroProductions.com

36
Graphics / How do I set transparent color of a sprite image ? [Solved]
« on: February 02, 2009, 09:46:46 pm »
Hi,

I am new to S.F.M.L.

I made a small demo that creates a window and displays a sprite image.
How do I set the transparent color of a sprite ?
I am loading a JPG image file into the Sprite.

Please look at this screenshot:

Any help would be appreciated!

JeZ+Lee
SLNTHERO@aol.com
Silent Hero Productions(R)
Video Game Design Studio
http://www.SilentHeroProductions.com

37
General / 1st Demo Using SFML - Only Get Console Window - HELP
« on: January 19, 2009, 02:11:00 pm »
1st Demo Using SFML - Only Get Console Window - HELP

Hi,

I am new to SFML.
I am using Microsoft Vista OS and my C++ IDE is Code::Blocks.
I followed the instructions properly to set up SFML with Code::Blocks.
I entered this simple demo from SFML web site:

Code: [Select]
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>

 int main()
 {
     // Create the main window
     sf::RenderWindow App(sf::VideoMode(640, 640), "SFML window");

     // Load a sprite to display
     sf::Image Image;
     if (!Image.LoadFromFile("cute_image.jpg"))
         return EXIT_FAILURE;
     sf::Sprite Sprite(Image);

     // Create a graphical string to display
     sf::Font Arial;
     if (!Arial.LoadFromFile("arial.ttf"))
         return EXIT_FAILURE;
     sf::String Text("Hello SFML", Arial, 50);

     // Load a music to play
     sf::Music Music;
     if (!Music.OpenFromFile("nice_music.ogg"))
         return EXIT_FAILURE;

     // Play the music
     Music.Play();

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

         // Clear screen
         App.Clear();

         // Draw the sprite
         App.Draw(Sprite);

         // Draw the string
         App.Draw(Text);

         // Update the window
         App.Display();
     }

     return EXIT_SUCCESS;
 }


It builds OK, but when I run it, I only get one console window with no 640x640 window. Also I see no test sprite, text, and OGG music playing? (I do have the test sprite JPG, font, and OGG in the directory of the executable.)

When I build above source in Code::Blocks under Windows Vista, I get the follow output:
Code: [Select]
-------------- Build: Debug in SFML_Beginning ---------------

Compiling: main.cpp
Linking console executable: bin\Debug\SFML_Beginning.exe
Info: resolving sf::Font::ourDefaultCharset      by linking to __imp___ZN2sf4Font17ourDefaultCharsetE (auto-import)
Info: resolving vtable for sf::Spriteby linking to __imp___ZTVN2sf6SpriteE (auto-import)
Info: resolving vtable for sf::Stringby linking to __imp___ZTVN2sf6StringE (auto-import)
C:\Program Files\CodeBlocks\MinGW\bin\ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.
Output size is 67.00 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 1 warnings


Again I am new to SFML.
If you can help me make this work I would appreciate it greatly.


JeZ+Lee
SLNTHERO@aol.com
Silent Hero Productions(R)
Video Game Design Studio
http://www.SilentHeroProductions.com

Pages: 1 2 [3]