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

Pages: [1] 2
1
Graphics / Getting colour of pixel underneath mouse position
« on: June 14, 2013, 01:07:04 pm »
I can't find any function that allows me to get r,g,b from current pixel. I might just not see it in documentation, any tip would be appreciated.

2
General / Need advice on "from what should I start"
« on: May 21, 2013, 06:59:48 pm »
Hi, so I have been waiting for SFML 2.0 to be released official and it finally happend.

And I also have more free time so I wanted to make SIMPLE BASE FUNDAMENTS for 2.5D RPG. I know that making full game by yourself is really hard and I don't even want to do it. I would be happy with working 2.5D rendering of world, animation of character and collision system.

Can someone give me advice from where to start? Should I start with 2.5D rendering, taking care of all aspects of view in 2.5D then move on?
What sould I write first?

And is it possible in CSFML 2.0 to handle Unicode characters without using other libraries?


Thanks in advance

3
General / Non ASCII characters
« on: July 06, 2011, 03:30:28 pm »
Hi, I'm from Poland and here we have special characters like:
ą,ę,ź,ż,ć,ó now i have a txt file where I have:
żźźżóóóóó
And of course when I'm trying to display it in SFML I get only óóóó, so I tried to add character set liek in tutorials:

sfUint32 zbior[] = {0x0104,0x0106,0x0118,0x0141,0x0143,0x00D3,0x015A,0x0179,0x017B,0x0105,0x0107,0x0119,0x0142,0x0144,0x00F3,0x015B,0x017A,0x017C,0x0};
   sfFont_CreateFromFile("arial.ttf",50,zbior);

And when I set this Font to string I get nothing displayed. Any solutions?
Should I convert all chars readed from file to sfUint32 array and use sfString_SetUnciodeText?

4
General / Double click event
« on: July 04, 2011, 11:38:08 am »
Okay, it's killing me. I know that there is no built in double click event so I wanted to implement it by my own with usage of clock. Default Windows value is 500ms so I tried to implement it by measuring time between each click but I can't get it to work. Can anyone post code to it or some advice?x_x

5
General / Questions about game programming
« on: June 21, 2011, 05:19:27 pm »
Hi, summer is coming and I wanted to create at least a base for MMORPG 2D isometric game, I say base because I know I won't achieve anything big in 2 months.

My questions:
1)Character can wear varius types of weapons, how can I "stick" image of for example sword into hand of character?
2)What about weather effect like snow,rain,desert storm. Should I use particile system?
3)When shaders can be useful?
4)What about lights and shadows in SFML?
5)What about collision detection, should I only mark some terrains as "nonclickable" and other as "clickable"
6)How should I maintain multiple clients? I think spawning 100 threads for 100 clients is a bit of performance waist?
7)About optimization I think drawing only what is visible and sending data about things that are in player's field of view
8 )I need simply GUI system, which GUI made in SFML can You recommend and why? I need simple buttons, entryboxes for single lines of text and windows.

Thanks in advance for help


Thanks in advance.

6
General discussions / When official SFML 2.0 is going to be realised?
« on: June 08, 2011, 09:10:59 am »
Hi, I just found Laurent post saying:
Quote
Definitely SFML 2. It's just one (or two) major feature away from the public release, the only thing that you have to take in account is that the graphics API will change a lot.

It was posted on 1 Jun.

I wonder when official release is going to happend because I want to use SFML in my project for summer project(coding will start in 1 month) and I would like to use official API and I know there are big differences between 1.6 and 2.0

7
General discussions / Updating SFML
« on: January 20, 2011, 09:19:31 pm »
Hello, it's rather quick and easy question but I wonder how updating SFML looks like? Right now I am using 1.6 and it's great library but when official 2.0 come out how updating look like? Will coping new libs and dlls be enough? Or will I have to do some changes in code?


Thanks in advance.

8
General / Map editor -questions
« on: December 30, 2010, 10:00:30 am »
Hello, as You all know guys adding elements one by one is kinda annoying so I decided as everyoen to create my own Map Editor, it's not going to be tile based. I will use GTK+ to create whole GUI system, but I have some question:
1)There are going to be some layers, like non-collising,collising,NPC etc and non collision is going to be the biggest one. I will create that layer from sprites for example 50x50 big and I want to place like 50 of them, now it will be ridiculous to later need to use 50 sprites in game to create background. Should I group the sprites into a big background image and save it as seperate file? and then just use one sprite for it? I think it will be a lot better solution.
2)How should save the fiel format, or all that data? I want to do simple file where it's all listed in several groups. Collision, NPC etc and then pack it to RAR file secured with password and durning game just unpack archieve and when closing game it would be automatically deleted, is it good way to secure somehow files from being changed?


Thanks in advance for answers, best regards Darek.

9
General / Collision and moving depends on collision point
« on: December 24, 2010, 06:41:20 pm »
Hello I have a scene like that:
http://img121.imageshack.us/img121/8286/grafq.jpg

Red is Your character, blue and black are obstacles.
Now I wanna to detect collision between them(works) and then I want to allow character to move only down if You collide with bottom part of object, move only up when You collide with top part of object and only right when You collide with right part of object and only left when You collide with left part of object. I thought about function which checks with which object You collide and then transfer Sprite to Rect and measure X and Y coords of Character like:
If Character's Y is lower than Bottom of colliding object then  allow to move only down etc.

Is it good solution? Maybe there is better one? By this way rect will be size of FULL picture including transparent pixels >> Should I update Collision function so it will return point of collision and with it I could operate or how to realize it? Or maybe just get center of obstacle and check if You are below it but still upper bottom? And then allow to move only down?

10
General / Perfect Collision Detection and explanation of functions
« on: December 16, 2010, 05:26:34 pm »
Hello, recently I found some free time to start adding basic functions to my game, now I want to create my own Perfect Collision Detections alogirthm, I don't want to use a coded one. What basically do I need to know about it? Which SFML function would I need?
I want to have semi-good performance so first I will test if rectangle-rectangle is found and then if it is I will process to pixel perfect collision detection, right?

And also I don't know what for really are following functions:
What is context? Like sfContext_Create?
sfImage_Bind ?
What are mutexs?
What is PostFX?
What is BlendMode?
sfShape_TransformToGlobal ?
sfShape_TransformToLocal ?
How excatly works setting HalfSize and Center of Views?

Thanks in advance for answers.

11
Audio / Error when tring to delete music file.
« on: December 09, 2010, 03:28:55 pm »
Okay, so bassicly I used unRAR library to unrar my archieve which constainst graphics and also sounds for my game, everything works fine till deleting.

I can easlie delete all graphic files but can't delete sounds file.

Here's problem:
I use one sfMusic* Pointer to all types of clicking so bassicly when You click in that area You get another sound and when You click in another area You get another sound.

I also got one background music, which deletes without any problems, I think it's because I use it only for one purpose.(background music ofcourse)

When i want to switch music in that one pointer I do something like:
Pointer = sfMusic_CreateFromFile(blabla);
And when I closing my game I do something like:
Code: [Select]

sfMusic_Destroy(Pointer);
system("RD /S /Q Dzwieki"); <- directory with sounds

And I get permission error saying that I am tring to delete something that is already in use.
But if I don't click anywhere and just close the game it deletes without problem.

So how should I prevent this?
It's not working because of adressing different types of files to that same pointer, I tried nulling this pointer everyime I change it's file but it's not helping. I am sure about that because just now I ran some test, do I have to use different sfMusic for every music file that I want? Come one there's got to be some kind of solution.

Minimal code of problem:
Code: [Select]

extern "C"
{
#include <SFML/System.h>
#include <SFML/Audio.h>
#include <SFML/Window.h>
}
int main() //Name of files are "aaa.ogg" and "aaa1.ogg"
{
sfMusic* Tescior = NULL; <--- used for test
sfWindowSettings Ustawienia = {24, 8, 0};
sfVideoMode Tryb = {800, 600, 32};
sfRenderWindow* Glowne;
sfEvent Wydarzenie;
Glowne = sfRenderWindow_Create(Tryb, "Gra v0.1 Alpha", sfClose, Ustawienia);
while (sfRenderWindow_IsOpened(Glowne))
{
while (sfRenderWindow_GetEvent(Glowne, &Wydarzenie)) //Pobiera Wydarzenia
{
if (Wydarzenie.Type == sfEvtClosed) //Jesli wydarzenie to X
{
sfRenderWindow_Close(Glowne);
}
if (Wydarzenie.Type == sfEvtKeyPressed && Wydarzenie.Key.Code == sfKeyQ)
{
Tescior = sfMusic_CreateFromFile("aaa.ogg");
sfMusic_Play(Tescior);
}
if (Wydarzenie.Type == sfEvtKeyPressed && Wydarzenie.Key.Code == sfKeyE)
{
Tescior = sfMusic_CreateFromFile("aaa1.ogg");
sfMusic_Play(Tescior);
}


}
}
sfRenderWindow_Clear(Glowne, sfBlack);
sfRenderWindow_Display(Glowne);
}
     sfRenderWindow_Destroy(Glowne);
sfMusic_Destroy(Tescior);
remove("aaa.ogg");
remove("aaa1.ogg");
getch();
     return EXIT_SUCCESS;
 }

12
General / Save's file
« on: November 29, 2010, 09:47:36 pm »
Helo users, I wonder hwo You secure Your save file from editting it by users?
Do You just encrypt it and then durining load decrypt it?
Do You basically store crypted save file in directory and then decrypt it durning game and when qutting just delete old save file, save new values to plain file and then crypting it? If so which algorithm do You use?


Thanks in advance.

13
General / Collision Detection and Animation confused
« on: November 16, 2010, 09:54:03 pm »
Hello, I just ended animation code and it has confused me because I can create mask and hide black background, but without mask it looks like that:



And if I would like to check collision beetwen sprite and another sprite(i.e. rock) then it probably will be wrong because Collision will be alarmed when Rock touch Black area of my character, right?

How can I avoid it? I can't test it because I don't have any collision detections, yet but I don't want to get in troubles later.

14
C / AniSprite from C++ to C
« on: November 16, 2010, 05:22:55 pm »
Okay, I'm trying to convert that but I can't, first I will show You my translated code. Oryginal code is here:
http://www.sfml-dev.org/wiki/en/sources/anisprite

AniSprite.C:
Code: [Select]

extern "C"
{
#include "AniSprite.h" //PAMIETAC O NAPISNIU sf_Destroyi na koncu!!!
int ZerujDane(AniSprite pedal);
int SetFrameSize(int frameW, int frameH, AniSprite pedal);
int GetFrameCount(AniSprite pedal);
sfIntRect GetFramePosition(int frame, AniSprite pedal);
int SetFrame(int frame, AniSprite pedal);
int SetLoopSpeed(float newfps, AniSprite pedal);
int PlayUstalone(int start, int end, AniSprite pedal);
int PlayZwykle(AniSprite pedal);
int Stop(AniSprite pedal);
int Update(AniSprite pedal);
//int Laduj(AniSprite pedal, int frameW, int frameH);
//int Laduj(AniSprite pedal);
}
int ZerujDane(AniSprite pedal)
{
pedal.duszek = NULL;
pedal.zdjecie = NULL;
pedal.clock = NULL;
pedal.fps = 1;
pedal.currentFrame=0;
pedal.isPlaying=false;
pedal.loopStart=0;
pedal.loopEnd=0;
pedal.frameHeight=0;
pedal.frameWidth=0;
return 1;
}
//int Laduj(AniSprite pedal, int frameW, int frameH)
//{
//pedal.zdjecie = sfImage_CreateFromFile("Character.png"); //SPRAWDZIC JESZCZE POTEm
//pedal.duszek = sfSprite_Create();
//sfSprite_SetImage(pedal.duszek, pedal.zdjecie);
//SetFrameSize(frameW, frameH, pedal);
//return 1;
//}

int SetFrameSize(int frameW, int frameH, AniSprite pedal)
{
pedal.frameWidth = frameW;
pedal.frameHeight = frameH;
sfIntRect pedal2;
pedal2.Left = 0;
pedal2.Top = 0;
pedal2.Right = frameW;
pedal2.Bottom = frameH;
sfSprite_SetSubRect(pedal.duszek,pedal2);
return 1;
}

int GetFrameCount(AniSprite pedal)
{
unsigned int across = (sfImage_GetWidth(pedal.zdjecie) / pedal.frameWidth);
unsigned int down = (sfImage_GetHeight(pedal.zdjecie) / pedal.frameHeight);
return across*down;
}
sfIntRect GetFramePosition(int frame, AniSprite pedal)
{
unsigned int across = (sfImage_GetWidth(pedal.zdjecie) / pedal.frameWidth);
unsigned int down = (sfImage_GetHeight(pedal.zdjecie) / pedal.frameHeight);

int tileY = frame / across;
int tileX = frame % across;
sfIntRect result; // MOZE ZMIENIC NA GLOBALNA ZMIENNA;
result.Left = tileX*pedal.frameWidth;
result.Top = tileY*pedal.frameHeight;
result.Right = tileX*pedal.frameWidth + pedal.frameWidth;
result.Bottom = tileY*pedal.frameHeight + pedal.frameHeight;
return result;
}
int SetFrame(int frame, AniSprite pedal)
{
pedal.currentFrame = frame;
return 1;
}

int SetLoopSpeed(float newfps, AniSprite pedal)
{
pedal.fps = newfps;
return 1;
}
int PlayUstalone(int start, int end, AniSprite pedal)
{
pedal.loopStart = start;
pedal.loopEnd = end;
pedal.currentFrame = start;
pedal.isPlaying = true;
sfClock_Reset(pedal.clock);
return 1;
}
int PlayZwykle(AniSprite pedal)
{
PlayUstalone(0, GetFrameCount(pedal), pedal); //ALBO TRZECI ARGUMENT NULL
return 1;
}
int Stop(AniSprite pedal)
{
pedal.isPlaying = false;
return 1;
}
int Update(AniSprite pedal)
{
if(pedal.isPlaying)
{
int frameCount = pedal.loopEnd - pedal.loopStart;
float timePosition = (sfClock_GetTime(pedal.clock) * pedal.fps);
pedal.currentFrame = pedal.loopStart + (int) timePosition % frameCount;
sfSprite_SetSubRect(pedal.duszek, GetFramePosition(pedal.currentFrame, pedal)); //ALBO TRZECI ARGUMENT NULL
}
return 1;
}


AniSprite.h:
Code: [Select]

#pragma once
extern "C"
{
#include <SFML/Graphics.h>
#include <SFML/Config.h>
#include <SFML/System.h>
typedef struct
{
sfImage* zdjecie;
sfSprite* duszek;
sfClock* clock;
float fps;
bool isPlaying;
int loopStart;
int loopEnd;
int currentFrame;
int frameWidth;
int frameHeight;
} AniSprite;
//int Laduj(AniSprite pedal, int frameW, int frameH);
//int Laduj(AniSprite pedal);
int ZerujDane(AniSprite pedal);
int SetFrameSize(int frameW, int frameH, AniSprite pedal);
int GetFrameCount(AniSprite pedal);
sfIntRect GetFramePosition(int frame, AniSprite pedal);
int SetFrame(int frame, AniSprite pedal);
int SetLoopSpeed(float newfps, AniSprite pedal);
int PlayUstalone(int start, int end, AniSprite pedal);
int PlayZwykle(AniSprite pedal);
int Stop(AniSprite pedal);
int Update(AniSprite pedal);
}


I'm trying to use it like that:
Code: [Select]

extern "C"
{
#include <SFML/System.h>
#include <SFML/Graphics.h>
#include <SFML/Window.h>
#include "AniSprite.h"
AniSprite test;
}
#include <iostream>
void Instaluj(sfSprite* duszek, sfImage* zdjecie, char* sciezka);
char* tabela[4] = {"natesty.jpg", "natesty2.jpg", "natesty3.jpg"};
int main()
 {
ZerujDane(test);
test.clock = sfClock_Create();
test.duszek = sfSprite_Create();
test.zdjecie = sfImage_CreateFromFile("character.png");
sfSprite_SetImage(test.duszek, test.zdjecie);
//SetFrameSize(47, 64, test);
int a;
a = SetFrameSize(47, 64, test);
if (a == 1)
{
std::cout << "Nie Spierdala sie" << std::endl;
}
//Laduj(test, 47, 64);
SetLoopSpeed(60, test);
//PlayZwykle(test);
PlayUstalone(4, 7, test);
     sfWindowSettings Settings = {24, 8, 0};
     sfVideoMode Mode = {800, 600, 32};
     sfRenderWindow* App;
     sfImage* Image = NULL;
     sfSprite* Sprite = NULL;
     sfEvent Event;
Sprite = sfSprite_Create();

     /* Create the main window */
     App = sfRenderWindow_Create(Mode, "SFML Testy", sfClose, Settings);
     if (!App)
         return EXIT_FAILURE;
Instaluj(Sprite, Image, tabela[0]);
sfRenderWindow_SetFramerateLimit(App, 60);
     /* Start the game loop */
     while (sfRenderWindow_IsOpened(App))
     {
//std::cout << test.frameHeight << std::endl;
//std::cout << test.frameWidth << std::endl;
         /* Process events */
         while (sfRenderWindow_GetEvent(App, &Event))
         {
             /* Close window : exit */
             if (Event.Type == sfEvtClosed)
                 sfRenderWindow_Close(App);
         }
 
         /* Clear the screen */
         sfRenderWindow_Clear(App, sfBlack);
Update(test);
 
         /* Draw the sprite */
         sfRenderWindow_DrawSprite(App, Sprite);
sfRenderWindow_DrawSprite(App, test.duszek);
 
 
         /* Update the window */
         sfRenderWindow_Display(App);
     }
 
     /* Cleanup resources */
     sfSprite_Destroy(Sprite);
     sfImage_Destroy(Image);
     sfRenderWindow_Destroy(App);
 
     return EXIT_SUCCESS;
 }


Some weird problems:
It shows that
test.frameHeight and test.frameWidth == 0 but why? I called function: SetFrameSize(47, 64, test);
But it shows that SetFrameSize return 1 so it should work...
Anyway when I launch app it runs without crash(woooo before I was crashing like shit) but I can only see:
and it doesn't animate itself.

Other weird shitty problems:
If I use PlayZwykle(test) it crash and shows You devining by 0:
Code: [Select]

int GetFrameCount(AniSprite pedal)
{
unsigned int across = (sfImage_GetWidth(pedal.zdjecie) / pedal.frameWidth); HERE
unsigned int down = (sfImage_GetHeight(pedal.zdjecie) / pedal.frameHeight); HERE
return across*down;
}


I bet it's because test.frameWidth and test.frameHeight are 0 but still can't figure out why....


I know that probably noone of You give shit about C version of SFML but I really do care about it and can't figure it out, if someone could help I would be grateful.

EDIT: THE SAME HAPPENS WITH FPS SETTING NO METTER WHAT I TRY TO SET THROUGHT FUNCTION IT ALWAYS IS 0 AND COMPILER IN COME CASES SAY THAT test structure is not inicialized.


God damn it help people please.

15
General / Maps, amimation, colission. some effects
« on: November 12, 2010, 01:02:45 pm »
Okay, sup there guys?
I finally made my main menu, new game menu, some pictures viewing, saving info to file and reading from file - basic stuff and now I need help from You guys, I got couple of questions:
1)I need tilemap map editor, I serched forum and found 2 intersting projects:
a) http://www.sfml-dev.org/forum/viewtopic.php?t=2340&start=45
b) http://www.sfml-dev.org/forum/viewtopic.php?t=1920
I wonder which one should I use? The game is top viewed.
Also if I use one of these editors how can I manage collisions with other objects like boundaries of map or other sprites? Also I dont' want to use .XML format.
I saw that SFMLMappy uses FMP format and it's also can handle isometric maps(I going to need that one in a future) - I will probably use this one editor but please give me some opinions.

2)I need to animate my character in game, You know move when I press A or W etc...
I saw that class to manage animations: http://www.sfml-dev.org/wiki/en/sources/anisprite
It's pretty cool, I think it will be enough right?
Also I want to use the same class to managa moving or trees or people in game, will it be possible?

3)How can i add some post effects like slowly moving string from top to bottom? I have to check if LastFrameTime is > 1s and if it is then change string position to lower?

Thanks in advance guys.

Pages: [1] 2
anything