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

Pages: 1 ... 3 4 [5] 6 7 ... 25
61
General / Re: Efficient way to draw and get pixels
« on: January 28, 2022, 12:32:26 pm »
moving GPU to CPU is always slow, unfortunately.
but in this case you could try an OpenGL function, like glReadPixels.

unsigned char data[4];
glReadPixels(sf::Mouse::getPosition(window).x, sf::Mouse::getPosition(window).y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &data);
 

62
to be honest I ran your code and didn't understood what is the problem

63
General / Re: C++ Version / Power Usage Very High
« on: January 22, 2022, 04:05:33 pm »
1- i think any of these would be good
2- you are probably running your program at max speed (as seens with 52% use of CPU). put a sleep in each iteration: https://www.sfml-dev.org/documentation/2.5.1/group__system.php#gab8c0d1f966b4e5110fd370b662d8c11b

something like
[your code]
window.clear();
window.draw(your sprites, etc);
window.display();
sf::sleep(sf::milliseconds(10));
 

64
you can also use the KeyReleased event instead. most games do that (except for text entering or other continuous actions, like moving the screen with the arrows)

65
Graphics / Re: How to make a functional main menu without headers?
« on: January 04, 2022, 06:08:47 pm »
if there are just .cpp files, the IDE linker will put everything together when you compile it.
you will just need to declare (but not necessarily define) variables and classes in all files they are used.

66
Graphics / Re: What is wrong with this code?
« on: December 02, 2021, 06:32:00 pm »
well, the first thing is probably here:
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) {
when spacebar is pressed, you are starting to shoot. the problem is that when you hit spacebar with your hand for like 0,1 second, the shoothing loop happens tons of times. the computer processes it really quick. so thats why it slows everything down, you are creating tons of bullets per second.

try changing it for sf::Event::KeyReleased :
https://www.sfml-dev.org/tutorials/2.5/window-events.php#the-keypressed-and-keyreleased-events


the second point is probably that you are clearing the window after drawing your bullets.

67
General / Re: if position with sfml
« on: November 26, 2021, 08:12:17 pm »

while (player position <= object position)
{
  //do anything
}

this is not really SFML related... have a check on some basic tutorials about loops and conditions (do, for, while)...

68
General / Re: if position with sfml
« on: November 26, 2021, 11:54:43 am »
I didn't know for sure if I got what you mean by "something to go as long as it is given inside the if".


do you want to move the slot1 to move around when you press some key on the keyboard? if that's it, check this:
https://www.sfml-dev.org/tutorials/2.5/window-inputs.php#keyboard

OBS.: you forgot to clear() the window in your code.

69
General / Re: codeblocks hell - back to SDL
« on: October 14, 2021, 02:34:07 am »
idk man, the distribuition is not actually mine. i'm just a simple user, but i can use SFML and Code::Blocks.

other than that, if you share the error we could help you get to the solution.

70
General / Re: codeblocks hell - back to SDL
« on: October 02, 2021, 10:27:26 pm »
so... did you post about it in CodeBlocks forums?

you can use SFML in any code editor, btw.

71
Graphics / Re: sf::Image loadFromFile is not working
« on: August 23, 2021, 03:12:34 am »
are you sure you're not mixing x86 and x64 libraries?
and also not mixing debug and release libraries?

72
Graphics / Re: Image with out of objects sf::Texture and sf::Sprite
« on: August 20, 2021, 01:31:53 pm »
the point in having separated textures and sprites is that you can reuse the same texture. sf::Texture is a heavier object that uses video ram. sf::Sprite is a lightweight object, that uses any texture loaded.
example: if you want to create 5 birds flying in your game, you just load one texture, like "bird.png", and create 5 sprites using the same texture. one 'heavy' object and 5 light objects. and you can also change the color of each sprite, even if they use the same texture.

73
Graphics / Re: Image with out of objects sf::Texture and sf::Sprite
« on: August 20, 2021, 01:56:47 am »
you don't need a lot of textures and sprites, you just need one of each for every image.
the way you are trying to do is simply wrong, you'd be creating and destroying the images every frame. thats too expensive to the cpu.

and sf::Image can't be drawn to the screen. you use it only when you need to change something in the image (as changing some pixel color).

74
Graphics / Re: Unique names for rectangles in class
« on: August 09, 2021, 07:42:17 am »
sf::RectangleShape rect[16];

75
Graphics / Re: How can I create a grid?
« on: July 21, 2021, 04:09:44 pm »
just draw some lines horizontally and then vertically

search 'Line without thickness' here:
https://www.sfml-dev.org/tutorials/2.0/graphics-shape.php

Pages: 1 ... 3 4 [5] 6 7 ... 25
anything