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

Pages: [1] 2 3
1
Graphics / Re: Problem when zooming
« on: May 02, 2023, 11:04:08 pm »
Thanks! Everything working now, it was simpler than I thought :D

2
Graphics / [SOLVED] Problem when zooming
« on: May 02, 2023, 05:41:25 pm »
Hi, I can't figure out what to do to make the text and the minimap stay in the same size when i zoom.
I zoom in the main view and the text and minimap that I'm drawing after the scene zooms also, I want them to stay the same size.
Should I create another view? As I understand the views overwrite each other, can I make a transparent View so I write the text and minimap over it and the rest is transparent so the back main view is viewed?
Or should I apply a counter-zoom to the text and the minimap?

3
Hi Raincode! I'll start working on sound and ambient soon, thanks for the suggestions!

4
SFML projects / Re: Top Down Soccer/Football game with SFML and BOX2D
« on: February 28, 2022, 07:27:02 pm »
I'm using 2D rendering, To simulate depth I calculate the height of the ball by code and I add the shadow accordingly and I added a simple shadow for the players.

5
SFML projects / Re: Top Down Soccer/Football game with SFML and BOX2D
« on: December 29, 2021, 11:45:21 pm »
Thanks Sk, no demo yet, probably in the next few months there will be one. I'm planning on releasing it on Steam, yes. Hopefully sometime in 2022. You can follow news on twitter: @guido_ion

6
SFML projects / Top Down Soccer/Football game with SFML and BOX2D
« on: December 29, 2021, 03:18:54 am »
Hey! I wanted to share with you my project, it's a soccer game with total control. I've always felt that mainstream soccer games (FIFA, PES) lack control over what you do, meaning, where you kick is approximate, your passes are approximate, etc. Also I've never found a soccer game that really does what I want it to do. Natural Soccer is good but not exactly what I want. Sensible Soccer is great but very limited.

So... I decided to try to do it myself. After 18 months of developing this is the current state. There's a lot to improve but I think it's going in the direction I want. A lot (I mean a lot) of develompment went (and still goes) to the handling of the players, it's 80% done. Art is basic, a lot to do there. AI is basic also, I will re do it, I'm still learning about AI.



Thanks! you can follow development on twitter @guido_ion

7
SFML projects / Re: Gamepad Class for SFML (using XInput and SDL database)
« on: December 22, 2021, 06:38:41 pm »
Update:
- XInput gamepad number is not always the same as the number provided by sf::Joystick, this is determined and handled properly by the Gamepad Manager.

This was an issue when connecting an XInput Gamepad and another not XInput Gamepad and the number assigned by XInput (always 0 if there is only one connected) didn't match the number provided by sf::Joystick which can be 0 or 1.

For this I added a Gamepad Manager that takes care of initializing and populating every Gamepad whether it is XInput or other and regardless of whether the XInput number matches or not the one provided by sf::Joystick.

8
Added support for events with the method "getButtonNumber(GAMEPAD_BUTTON btn)"

Code: [Select]
if (_currentEvent.type == sf::Event::EventType::JoystickButtonReleased && _currentEvent.joystickButton.joystickId == 0 && _currentEvent.joystickButton.button == _gamepadOne->getButtonNumber(Gamepad::GAMEPAD_BUTTON::btn_start))
  /// do something

This is to avoid checking many times the same button.

9
Graphics / Re: Position a sprite relative to another
« on: October 25, 2021, 08:11:46 pm »
Solved with heading and side vectors using Box2D

Code: [Select]
void FieldPlayer::draw()
{
sf::Vector2f spritePos = sf::Vector2f(Game::SCALE * m_body->GetPosition().x, Game::SCALE * m_body->GetPosition().y);
float degreesOfRotation = Game::RadiansToDegrees(m_body->GetAngle());

m_sprite.setPosition(spritePos);
m_sprite.setRotation(degreesOfRotation);
Game::GetWindow()->draw(m_sprite);

if (PlayerState.sliding) {
// 80cm to the back of the player (local y axis)
b2Vec2 headPosSliding = m_body->GetPosition() - (0.8 * getHeading());
// 24cm to the left of the player (local x axis)
headPosSliding -= 0.24f * getSide(false);
spritePos = Game::BoxVecToSfVec(headPosSliding);
// slightly to the right of the body
degreesOfRotation += 30.f;
}

head_sprite.setPosition(spritePos);
head_sprite.setRotation(degreesOfRotation);
Game::GetWindow()->draw(head_sprite);
}

 :D

10
Graphics / Re: Position a sprite relative to another
« on: October 22, 2021, 06:49:08 pm »
The values are aproximatelly, I've tested several values, later when it works I'll put the correct values.
I've made some progress with this code:

Code: [Select]
void FieldPlayer::draw()
{
m_sprite.setPosition(Game::SCALE * m_body->GetPosition().x, Game::SCALE * m_body->GetPosition().y);
m_sprite.setRotation(Game::RadiansToDegrees(m_body->GetAngle()));
Game::GetWindow()->draw(m_sprite);

sf::Vector2f offset(0.f, 0.f);
if (PlayerState.sliding) offset = sf::Vector2f(-1.4f, -0.8f);

head_sprite.setPosition(Game::SCALE * (m_body->GetPosition().x + offset.x), Game::SCALE * (m_body->GetPosition().y + offset.y));
head_sprite.setRotation(Game::RadiansToDegrees(m_body->GetAngle()));
Game::GetWindow()->draw(head_sprite);
}

The head moves but in world coordinates, I have to take into consideration rotation yet, I can't figure out how.
GIF: [https://gfycat.com/recklesssoupycollardlizard]

And about the vector overload, it won't let me do this  ???:
Code: [Select]
m_sprite.setPosition(Game::SCALE * m_body->GetPosition());

11
Graphics / [Solved] Position a sprite relative to another
« on: October 21, 2021, 10:03:22 pm »
Hi, I'm trying to position a sprite relative to another. I have 2 sprites, one for the character and one for the head. The view is top down, when he is standing the head and character are aligned but when I do a slide the head remains in the center, I need to position the head in the correct place applying and offset form the center. How can I achieve this? I leave a beautiful image discribing the problem  ;)

I have this code but the translation isn't working, I can't see the head (it might be outside the screen)
Code: [Select]
void FieldPlayer::draw()
{
m_sprite.setPosition(Game::SCALE * m_body->GetPosition().x, Game::SCALE * m_body->GetPosition().y);
m_sprite.setRotation(Game::RadiansToDegrees(m_body->GetAngle()));
Game::GetWindow()->draw(m_sprite);

head_sprite.setPosition(Game::SCALE * m_body->GetPosition().x, Game::SCALE * m_body->GetPosition().y);
head_sprite.setRotation(Game::RadiansToDegrees(m_body->GetAngle()));
// move the head back if sliding
if (PlayerState.sliding) {
sf::Transform t = head_sprite.getTransform();
t.translate(-52.f, -10.f); ???
Game::GetWindow()->draw(head_sprite, t);
}
else {
Game::GetWindow()->draw(head_sprite);
}
}

Note: I need the code to consider rotations also

12
Uploaded!

https://github.com/GuidoBisocoli/SFML_GamepadSupport

I added XInput support and other things, still some things to do and also check more gamepads. MIT license  :)

13
Window / Re: Gamepad Class that reads from SDL controller database
« on: October 09, 2021, 12:15:55 am »
Done, I made a post in the Projects section :): https://en.sfml-dev.org/forums/index.php?topic=28250.msg176807

14
SFML projects / Gamepad Class for SFML (using XInput and SDL database)
« on: October 09, 2021, 12:12:19 am »
Hi guys I wanted to share this class that I made that uses SDL's controller database. I started looking for a gamepad db for SFML and I noticed that it is a common request from users so I decided to do it myself.

https://github.com/GuidoBisocoli/SFML_GamepadSupport


Features:
  • It supports Left and Right Trigger as button or axis seamlessly
  • It manages inverted axes

TO DO:
  • Support for dpad
  • Hide buttons, axes and triggers, now they are public
  • Read also linux and MacOs gamepads
  • Test gamepads

I've only tested it with my 2 gamepads (Logitech Dual Action and Controller (XBOX 360 For Windows)) and it works great, if you can help testing other gamepads please comment and let us know.

15
Window / Re: Gamepad Database: using SDL's database?
« on: October 07, 2021, 03:46:01 am »
Ok, I found that the GUID includes the vendorID and the productID, example:

Code: [Select]
030000005e040000d102000000000000
        \__/    \__/
       vendor  product

vendor: 5e04 -> 0x045e Hex -> 1118 decimal (Microsoft)
product: d102 -> 0x02d1 Hex -> 721 decimal (Xbox One Controller)

I'm now working on a generic GamePad Class that receives vendorID and productID and grabs the data from SDL's controllers database and also provides a nice interface to check buttons and axes.

When it's done I'll share it with the community  :D

Pages: [1] 2 3
anything