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

Pages: [1] 2
1
Graphics / Scaled Tiles
« on: January 01, 2010, 05:26:44 pm »
I want get scaled tile on my screen.

Edit. I forgot Imag.Copy. Sorry for making problems.

2
Graphics / Scaled Tiles
« on: January 01, 2010, 03:31:55 pm »
What will be best way to solve my problem? I tried

Code: [Select]

float Scale = Tileset.GetHeight() * 1.0f /Field_Size ;
sf::IntRect Rect((Element_Type*Tileset.GetHeight()) * Scale, 0, (Tileset.GetHeight()) * Scale, (Tileset.GetHeight())*Scale);
Tileset_Sprite.SetScale(Scale,Scale);Tileset_Sprite.SetSubRect(Rect);Tileset_Sprite.SetPosition(Field_Pos_X, Field_Pos_Y);
Render->Draw(Tileset_Sprite);


But it don't works.

Maybe is possible to make sprite from part of another sprite, but I don't found it. Any suggestions?

3
Graphics / Thin Shapes + views
« on: December 12, 2009, 10:34:55 pm »
It's graphics editor, and theres many corresponding classes...

4
Graphics / Thin Shapes + views
« on: December 12, 2009, 09:48:14 pm »
No :C I'm not drawing much, just square on screen and using view.zoom(ex. if i zoom to 200% i can see 2 lines, not square).

5
Graphics / Thin Shapes + views
« on: December 12, 2009, 12:27:59 pm »
I have problem with it. Example if i make square with 1 outlining, and next zoom view some edges dissapears. Is possible to fix it?

6
Graphics / Render to image
« on: November 18, 2009, 09:17:46 am »
What u mean with SFML 2? SVN version? I looked for this function in svn doc, but found nothing. Where to download it?

Edit:
Why in sfml2 shader can be draw only with image? Now if i want blur image multiple times i must do smthing like this:
Code: [Select]

        int Number_Of_Blurs = 0;
for(int i = 0; i < Number_Of_Blurs; i++)
{
sf::Image Temp_Image = Image_Render.GetImage();
sf::Sprite Blur_Image(Temp_Image);
Image_Render.Clear();
Image_Render.Draw(Blur_Image, Effect);
Image_Render.Display();
}


And why no doc in SVN? :F

7
Audio / Sounds not playing
« on: November 17, 2009, 06:47:26 pm »
Project is too complicated, but some pples tested my app and on their pc's all is ok.

8
Audio / Sounds not playing
« on: November 17, 2009, 04:04:30 pm »
Notching changed...

9
Audio / Sounds not playing
« on: November 17, 2009, 09:00:43 am »
Ya, sound buffer is global value, that is loaded in main function and never changes. I asked friend and on he's computer it works fine. If u have redists for MSV2k8 mb u can check too( http://www.unreal_world.w.interia.pl/Debug.rar )? Maybe my soundcard is broken or smthing...

10
Audio / Sounds not playing
« on: November 16, 2009, 10:57:39 pm »
So i have class menu, that organizes things like buttons, lists, boards etc.

Code: [Select]
sf::Sound Button_Click;

I'm loading sounds with this:

   
Code: [Select]

void Menu::Create_Buttons((...), sf::SoundBuffer &Snd_Over, sf::SoundBuffer &Snd_Click)
{
for(unsigned int i = 0; i < Number buttons(); i++)
{
sf_gui::Button New_Window;
                         [...]
New_Window.Button_Over.SetBuffer(Snd_Over);
New_Window.Button_Click.SetBuffer(Snd_Click);
Windows.insert(Windows.end(), New_Window);
}

}


And menu have method thad moves touch all buttons and playing sound if necessary:

Code: [Select]

if clicked on button
{
if(Clicked == true)
{
if(Is_Click_Played == false)
{
Button_Click.Play();
Is_Click_Played = true;
}
State = 2;
Result = true;

}
}
else Is_Click_Played = false;

11
Audio / Sounds not playing
« on: November 16, 2009, 10:02:01 pm »
I have problem with playing sounds. Sometimes sound not playing but it have good buffer and Play() is called. I have menu class that contains sf::Sound and global SoundBuffer. Menu is maked like tree, sounds work in 1st lvl, but in lower not. Setting new sound instance manually and using Play() works only on 1st lvl of menu(or main function), in lower not. When i get up from menu sounds are played normaly.

I am sure, that buffer are not changed after entering menu(find al references). Can someone help? Here is limit of instances that can use one buffer, or smthing?

12
Window / Input with winapi?
« on: October 25, 2009, 01:18:04 pm »
It is!

Code: [Select]
int Mouse_X = Render->GetInput().GetMouseX(), Mouse_Y = Render->GetInput().GetMouseY();

13
Window / Input with winapi?
« on: October 25, 2009, 11:37:44 am »
But u checking mouse coords from winapi or SFML? To see pos from SFML switch comments in fuction Display_FPS(this line with sprintf).

14
Window / Input with winapi?
« on: October 24, 2009, 11:15:05 pm »
Here is main.h
Code: [Select]

#ifndef Main_H
#define Main_H

#include <vector>
#include <windows.h>

//SFML graphics
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

//main values
extern sf::RenderWindow *Render;

#endif


Main.cpp
Code: [Select]

#include "Main.h"

#define WIN32_LEAN_AND_MEAN
#pragma warning (disable : 4996)

int mouse_x, mouse_y;

sf::RenderWindow *Render;



//FPS and Delta Time
    int FPS_Frames;
    float DeltaTime;
    sf::Clock FPS_Timer;
float FPS_Number, FPS_Time;

int FPS;
//zmienne okienka
   HWND hWindow, Render_Window;
   MSG Msg;
// nazwa klasy okna
   std::string WindowClass = "Window";
   std::string WindowCaption = "Caption";



void Display_FPS();
LRESULT CALLBACK WindowEventProc(HWND hWindow, UINT uMsg,WPARAM wParam, LPARAM lParam);
//----------------------- funkcja WinMain()----------------------------

 

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow)

{

   WNDCLASSEX KlasaOkna;
   ZeroMemory (&KlasaOkna, sizeof(WNDCLASSEX));
   KlasaOkna.cbSize = sizeof(WNDCLASSEX);
   KlasaOkna.hInstance = hInstance;
   KlasaOkna.lpfnWndProc = WindowEventProc;
   KlasaOkna.lpszClassName = WindowClass.c_str();
   KlasaOkna.hCursor = LoadCursor(NULL, IDC_ARROW);
   KlasaOkna.hIcon = LoadIcon(NULL, IDI_APPLICATION);
   KlasaOkna.hbrBackground = (HBRUSH) COLOR_WINDOW;
   RegisterClassEx (&KlasaOkna);

   // tworzymy okno funkcją CreateWindowEx
   hWindow = CreateWindowEx(NULL,                   // rozszerzony styl
                          WindowClass.c_str(), // klasa okna
                          WindowCaption.c_str(),       // tekst na p. tytułu
                          WS_SYSMENU,   // styl okna
                          CW_USEDEFAULT,         // współrzędna X
                          CW_USEDEFAULT,         // współrzędna Y
                          800,         // szerokość
                          600,         // wysokość
                          NULL,                  // okno nadrzędne
                          NULL,                  // menu
                          hInstance,             // instancjs aplikacji
                          NULL);                 // dodatkowe dane

   // pokazujemy nasze okno

DWORD Style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS;
HWND  Render_Window = CreateWindow("STATIC", NULL, Style, 0,  0, 800, 600, hWindow, NULL, hInstance, NULL);
sf::RenderWindow View01(Render_Window);
Render = &View01;
ShowWindow (hWindow, SW_SHOW);


while (Msg.message != WM_QUIT)
{
   if (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
   {
         TranslateMessage (&Msg);
         DispatchMessage (&Msg);
   }
   else
   {
    sf::Event Event;
    while (Render->GetEvent(Event))
    {
        // Process event
    }



Display_FPS();


Render->Clear(sf::Color(255, 255, 255));


Render->Display();
   }
}

return static_cast<int>(Msg.wParam);// zwracamy kod wyjścia
}
LRESULT CALLBACK WindowEventProc(HWND hWindow, UINT uMsg,WPARAM wParam, LPARAM lParam)
{
   switch (uMsg)
   {
      case WM_CREATE:
      break;
      case WM_DESTROY: // kończymy program
               PostQuitMessage (0);
               return 0;
      break;
 case WM_MOUSEMOVE:
      {
 mouse_x = LOWORD(lParam);
                      mouse_y = HIWORD(lParam);
      }
break;
   }
   return DefWindowProc(hWindow, uMsg, wParam, lParam);
}

void Display_FPS()
{
   //delta time calculate
      DeltaTime = FPS_Timer.GetElapsedTime();
  FPS_Timer.Reset();
   //FPS calculate
   ++FPS_Frames;//add frame
FPS_Time += DeltaTime;//time of generating one frame
if (FPS_Time >= 1.0f)   // czy minęła sekunda?
{
 FPS_Number = FPS_Frames / FPS_Time;//calculate fps
 FPS_Frames = 0;//reset frame number
 FPS_Time = 0.0f;//reset time
}

std::string tmp, tmp2, tmp3; // brzydkie rozwiązanie
itoa((int)FPS_Number, (char*)tmp.c_str(), 10);

std::string Caption = "Caption ";
Caption += tmp.c_str();
char Buffer[255];
int Mouse_X = Render->GetInput().GetMouseX(), Mouse_Y = Render->GetInput().GetMouseY();
//sprintf( Buffer, " MouseX: %d MouseY: %d", Mouse_X, Mouse_Y);
sprintf( Buffer, " MouseX: %d MouseY: %d", mouse_x, mouse_y);
Caption += Buffer;
SetWindowText(hWindow, Caption.c_str());
}


And linker input:
Code: [Select]

sfml-system-s-d.lib sfml-main-d.lib sfml-window-s-d.lib sfml-graphics-s-d.lib

Project is much bigger i cut object etc classes, and other not important things(it's commercial and not only my project, so i can't paste here all).

15
Window / Input with winapi?
« on: October 24, 2009, 10:00:30 pm »
But it's complete... There is only functions ex. displaying fps on window caption etc.

Code: [Select]

#include "Main.h"
#define WIN32_LEAN_AND_MEAN
sf::RenderWindow *Render;
int mouse_x, mouse_y;

//FPS and Delta Time
    int FPS_Frames;
    float DeltaTime;
    sf::Clock FPS_Timer;
float FPS_Number, FPS_Time;

int FPS;
//zmienne okienka
   HWND hWindow, Render_Window;
   MSG Msg;
// nazwa klasy okna
   std::string WindowClass = "Window";
   std::string WindowCaption = " ";

b2AABB WorldSize;

b2Vec2 gravity(0.0f, 0.0f);
bool doSleep = true;

//zasoby

//obrazki
sf::Image Img_Button[2];

//fonty
sf::Font Fnt_Arial, Fnt_Times_New_Roman;

void Display_FPS();
LRESULT CALLBACK WindowEventProc(HWND hWindow, UINT uMsg,WPARAM wParam, LPARAM lParam);
//----------------------- funkcja WinMain()----------------------------

 

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow)

{


   WNDCLASSEX KlasaOkna;
   ZeroMemory (&KlasaOkna, sizeof(WNDCLASSEX));
   KlasaOkna.cbSize = sizeof(WNDCLASSEX);
   KlasaOkna.hInstance = hInstance;
   KlasaOkna.lpfnWndProc = WindowEventProc;
   KlasaOkna.lpszClassName = WindowClass.c_str();
   KlasaOkna.hCursor = LoadCursor(NULL, IDC_ARROW);
   KlasaOkna.hIcon = LoadIcon(NULL, IDI_APPLICATION);
   KlasaOkna.hbrBackground = (HBRUSH) COLOR_WINDOW;
   RegisterClassEx (&KlasaOkna);

   // tworzymy okno funkcją CreateWindowEx
   hWindow = CreateWindowEx(NULL,                   // rozszerzony styl
                          WindowClass.c_str(), // klasa okna
                          WindowCaption.c_str(),       // tekst na p. tytułu
                          WS_SYSMENU,   // styl okna
                          CW_USEDEFAULT,         // współrzędna X
                          CW_USEDEFAULT,         // współrzędna Y
                          800,         // szerokość
                          600,         // wysokość
                          NULL,                  // okno nadrzędne
                          NULL,                  // menu
                          hInstance,             // instancjs aplikacji
                          NULL);                 // dodatkowe dane

   // pokazujemy nasze okno

DWORD Style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS;
HWND  Render_Window = CreateWindow("STATIC", NULL, Style, 0,  0, 800, 600, hWindow, NULL, hInstance, NULL);
sf::RenderWindow View01(Render_Window);
Render = &View01;
ShowWindow (hWindow, SW_SHOW);

while (Msg.message != WM_QUIT)
{
   if (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
   {
         TranslateMessage (&Msg);
         DispatchMessage (&Msg);
   }
   else
   {
    sf::Event Event;
    while (Render->GetEvent(Event))
    {
        // Process event
    }



Display_FPS();


Render->Clear(sf::Color(255, 255, 255));
//some display functions
Button.Display(Render, DeltaTime);

Render->Display();
   }
}

return static_cast<int>(Msg.wParam);// zwracamy kod wyjścia
}
LRESULT CALLBACK WindowEventProc(HWND hWindow, UINT uMsg,WPARAM wParam, LPARAM lParam)
{
   switch (uMsg)
   {
      case WM_CREATE:
      break;
      case WM_DESTROY: // kończymy program
               PostQuitMessage (0);
               return 0;
      break;
//mouse move by winapi
 case WM_MOUSEMOVE:
      {
 mouse_x = LOWORD(lParam);
                      mouse_y = HIWORD(lParam);
      }
 break;
   }
   return DefWindowProc(hWindow, uMsg, wParam, lParam);
}
void Display_FPS()
{
   //delta time calculate
      DeltaTime = FPS_Timer.GetElapsedTime();
  FPS_Timer.Reset();
   //FPS calculate
   ++FPS_Frames;//add frame
FPS_Time += DeltaTime;//time of generating one frame
if (FPS_Time >= 1.0f)   // czy minęła sekunda?
{
 FPS_Number = FPS_Frames / FPS_Time;//calculate fps
 FPS_Frames = 0;//reset frame number
 FPS_Time = 0.0f;//reset time
}

std::string tmp, tmp2, tmp3; // brzydkie rozwiązanie
itoa((int)FPS_Number, (char*)tmp.c_str(), 10);

std::string Caption;
Caption += tmp.c_str();
char Buffer[255];
int Mouse_X = Render->GetInput().GetMouseX(), Mouse_Y = Render->GetInput().GetMouseY();
//sprintf( Buffer, " MouseX: %d MouseY: %d", Mouse_X, Mouse_Y); - currently using Winapi input
sprintf( Buffer, " MouseX: %d MouseY: %d Button %d", mouse_x, mouse_y, Button.State);
Caption += Buffer;
SetWindowText(hWindow, Caption.c_str());
}

Pages: [1] 2