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

Pages: [1]
1
Window / Re: How to keep my mouse in the window?
« on: March 22, 2014, 06:51:28 am »
Thx you so much :D

2
Window / How to keep my mouse in the window?
« on: March 21, 2014, 10:10:53 pm »
Hello!
How i can keep mouse in my created window (app) all the time and don't let it go from it?

i used this method but it's working very bad. Have any idea?

if (focus == true && Mouse::getPosition(app).x < 0) Mouse::setPosition(sf::Vector2i(0, Mouse::getPosition(app).y), app);

if (focus == true && Mouse::getPosition(app).x > xResolution) Mouse::setPosition(sf::Vector2i(xResolution - 5, Mouse::getPosition(app).y), app);

if (focus == true && Mouse::getPosition(app).y < 0) Mouse::setPosition(sf::Vector2i(Mouse::getPosition(app).x, 0), app);

if (focus == true && Mouse::getPosition(app).y > yResolution) Mouse::setPosition(sf::Vector2i(Mouse::getPosition(app).x, yResolution - 5), app);

3
General / Game Resources. How does it work?
« on: March 21, 2014, 04:47:03 pm »
Can you say me, how can I protect data files (music, textures and other) in my game. For example, in good games there are so many files with strange format and i cant open them with my archiver or Notepad++.

4
Window / Сooldown key presses
« on: March 21, 2014, 12:45:16 pm »
Hello!
I work on my project and there is one question.
I have action-game where the man shoots at the target. If i use

if((event.type == Event::KeyPressed) && (event.key.code == Keyboard::E)) Shot();

then my man shot a lot of! How can I slow down the process?
Maybe with clock help? Or should be used for the addition of one variable that stores reloading?

5
Upd. I fix that :)
My method - i have 2 type of coordinates
The fist - x,y in game (same background size)
The second - X,Y when i draw all objects (X = x*K)

6
I worked with my method and i saw the other problem.
I have 2 image:
Background 1920x1080
Human 118X112

        float xInMap=0.055, yInMap=0.775; //Human's X, Y
   float xResolution = 1200, yResolution = 510; //Selected resolution
   float K = yResolution/1080;

   sprite.setTextureRect(IntRect(0,0,1920,1080)); //My background
   sprite.setPosition(-0.01*xResolution,0); //Background Position

   sKyb.setTextureRect(IntRect(0, 0, 118, 112)); //My human
   sKyb.setPosition(xInMap*xResolution, yInMap*yResolution); //Human position

   sKyb.setScale(K, K);
   sprite.setScale(K, K);

   
   float xImage = xInMap*xResolution, yImage = yInMap*yResolution; //Position for drawing


   RenderWindow app(VideoMode(xResolution, yResolution), "Test Window");
In one situation human stay at one place(in background). Example: stands at the door, which drawed in background. Then i changed resolution and after that the human didn't stay at the door :(

I know where is the problem but i don't know how to fix it:
The problem in the Scale. When i scaled background, i changed the position of door.
But plz don't advise me that i must work with image where human are with size 1920x1080 (it's load pc a lot) and don't advise me that i must work with door separately coz in future i need to work with background.
Hope that you understand me, coz i lost my brain an hour ago and i sure that i wrote nonsense  ;D
This picture help you to understand me
in this image i used 1280x720


in this image i used 900x800 (it's not the one of resolutions where i saw the problem)

7
Hm, ok. I will read this.
But what do you think about my method with  the screen resolution. Is it right? I saw a lot of games and I played with their  the screen resolution system after that i wrote my method.

8
1) Implementation of FPS in games (FPS) How it works? What's the best way? If you use just a cycle and then drawing and calculation of properties of objects then the speed of the game will depend on the performance of your PC. (I use the time between 1 cycle  tact. After that i multiply all the calculations but this method has many disadvantages.)  8)

2) How to draw objects window, if I change the screen resolution?
My method: all graphics has 1920x1080
I divide the selected resolution (K = selected height / 1080), then I use the scale in SFML reduces the width and height of the window after recreates the selected screen resolution. I think - this is not the right solution, because this method at work show lags (probably it connected with a lack of FPS system)  ::)




Pages: [1]
anything