Welcome, Guest. Please login or register.

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

Pages: [1] 2 Next
1
SFML projects / Neural Network + Genetic Algorithm
« on: December 06, 2017, 02:23:09 pm »
After watching a lot of videos on YouTube I had some fun playing with neural networks + genetic algorithm. Don't know what else to say  :D

Source code: https://github.com/achpile/neural




2
Graphics / Mac OS X - High Sierra - RenderTexture::clear
« on: November 13, 2017, 02:58:50 pm »
Hey guys! I have some troubles with clearing render textures (or may be RenderWindow). And made some investigations. Here's the code:

#include "include/SFML/Graphics.hpp"

int main() {
        sf::RenderWindow app(sf::VideoMode(400,400), "test");
        sf::RectangleShape a(sf::Vector2f(10,10)), b(sf::Vector2f(1,1));

        sf::RenderTexture tex;
        sf::Sprite spr;

        tex.create(400,400);
        tex.setActive();
        tex.clear(sf::Color(0,0,0,0));
        int pos = 10;
        spr.setTexture(tex.getTexture());

        while (app.isOpen()) {
                sf::Event event;
                while (app.pollEvent(event)) {
                        if (event.type == sf::Event::Closed)
                                app.close();
                }

                pos += 1;
                a.setPosition(sf::Vector2f(pos, 10));

                app.clear();

                // Uncomment this to fix
                //app.draw(b);

                tex.draw(a);
                tex.display();
                app.draw(spr);

                tex.clear();
                app.display();
        }
}

 

If there's no draw calls on RenderWindow except the one with drawing RenderTexture it leads to some artifacts.
I attached the image from my game and from the example. As you can see - there's kinda trail, but it is not the same as without "clear" call.

And there were no such issues before High Sierra update.

3
SFML website / SFMLProjects
« on: November 04, 2017, 11:21:02 am »
I can't remember if i saw a topic here or just was talking about it with Exploiter long ago, but maybe it's a good idea to provide a link to sfmlprojects.org at Community page.  :)

4
Graphics / sf::RenderTexture without 'display' call.
« on: October 30, 2017, 01:21:56 pm »
Don't know if it's a bug, but if I don't call 'display' function - render texture draws upside down.

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

int main() {
        sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
        sf::Event event;
        sf::Font font;
        sf::Text text;
        sf::RectangleShape shape;
        sf::Sprite spr;
        sf::RenderTexture tex;

        font.loadFromFile("font.ttf");

        text.setFont(font);
        text.setString("HELLO");
        text.setCharacterSize(200);
        text.setFillColor(sf::Color::Black);

        shape.setSize(sf::Vector2f(100,100));
        shape.setPosition(100, 300);
        shape.setFillColor(sf::Color::Black);

        tex.create(800,600);
        tex.setActive(true);

        tex.clear(sf::Color::White);
        tex.draw(text);
        tex.draw(shape);
        //tex.display();

        spr.setTexture(tex.getTexture());

        while (window.isOpen()) {
                while (window.pollEvent(event)) if (event.type == sf::Event::Closed) window.close();

                window.clear(sf::Color::White);
                window.draw(spr);
                window.display();
        }

        return 0;
}
 

1.png - with 'display' call
2.png - without

5
Graphics / sf::Text and Outline
« on: October 24, 2017, 08:30:38 am »
Hello  :) Is there a way to make outline only outer space with text? As you can see it works fine with shapes, but text outlined inside and outside.

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

int main() {
        sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
        sf::Event event;
        sf::Font font;
        sf::Text text;
        sf::RectangleShape shape;

        font.loadFromFile("font.ttf");

        text.setFont(font);
        text.setString("HELLO");
        text.setCharacterSize(200);
        text.setFillColor(sf::Color(255,0,0,128));
        text.setOutlineColor(sf::Color(0,0,0,128));
        text.setOutlineThickness(5);

        shape.setSize(sf::Vector2f(100,100));
        shape.setPosition(100, 300);
        shape.setFillColor(sf::Color(255,0,0,128));
        shape.setOutlineColor(sf::Color(0,0,0,128));
        shape.setOutlineThickness(5);

        while (window.isOpen()) {
                while (window.pollEvent(event)) if (event.type == sf::Event::Closed) window.close();

                window.clear(sf::Color::White);
                window.draw(text);
                window.draw(shape);
                window.display();
        }

        return 0;
}
 


6
SFML projects / AchBall is now available on Steam
« on: September 27, 2017, 04:38:19 pm »
I decided to remaster a game I made 7-8 years ago :D Gameplay is very simple - you must hit the target by the ball. Each wall hit gives you 10 points. Yeah, that's all ;D

To make gameplay more interesting there are different achievements, leaderboards and some different things on stages, like moving platforms, fragile blocks etc.

Steam store page: http://store.steampowered.com/app/739180


7
SFML projects / Dispersio 2
« on: June 28, 2017, 12:38:20 pm »
Engine is almost finished, so here's a tech-demo :) Now it's time to start making content: locations, enemies, bosses etc. Probably I will post here screenshots later :)


8
SFML projects / Dispersio is now available on Steam!
« on: June 16, 2016, 09:17:29 pm »
Dispersio is now available on steam!

http://store.steampowered.com/app/563180

Story
After a disastrous geological experiment, the Earth was ruptured into dozens of asteroids, some of which hold remnants of what humanity had left behind. Many space travelers explore these asteroids in search of treasures and ancient relics. It took approximately twenty years to gather information about the location of the mysterious ancient crystal, which will give arcane power to whoever first obtains it - and so our brave hero seizes the chance to go on a perilous adventure and be the one to unearth the crystal. Who knows where it will lead?

Gameplay
Dispersio is a retro-styled action platformer. As you progress through the game, you will have to use and combine special abilities, such as dashing, wall-jumping and more.

There's even a hard mode for hardcore players. Can you beat each level without dying?

Features
  • Precisely tuned platforming mechanics
  • Interesting, detailed and challenging maps
  • 7 different abilities
  • Lots of secrets
  • A great unique soundtracks
  • Achievements
  • Gamepad support



Greenlight message:
(click to show/hide)

Old message:
(click to show/hide)

9
Feature requests / More Events
« on: April 18, 2016, 11:39:26 am »
What about to add some more events? For example: DROPFILES and HOTKEY.

10
SFML projects / Timer for speedruns "Stopwatch"
« on: April 17, 2016, 10:02:09 pm »
Made it just for one day  :D Coding speedrun  ;D

Well, after browsing web for a good speedrun timer didn't find anything nice for linux and decided to write my own.

More detailed description can be found here: https://github.com/achpile/asplit/releases/tag/v1.0-rc1


11
Window / Joystick axes
« on: April 21, 2015, 08:07:06 am »
This is the strangest thing I ever seen. I have a joystick "EXEQ Spitfire" and tested it on 4 different systems:

  • Linux 32bit laptop ASUS X200CA
  • Linux 64bit (Ubuntu 14.10) at home
  • WinXP 32bit at home
  • Linux 64bit (Ubuntu 14.10) at work

All the linux systems throw me two messages to console:
Unable to get joystick attribute. Could not find USB device for joystick at index 0.
Unable to get joystick attribute. Could not find USB device for joystick at index 0.
 

This code:
printf("[%u : %u] %s\n", sf::Joystick::getIdentification(0).vendorId,
    sf::Joystick::getIdentification(0).productId,
    sf::Joystick::getIdentification(0).name.toAnsiString().c_str());
 

Gives me:
[0 : 0] Microntek              USB Joystick
 

Well, about the problem:

Linux 64bit (Ubuntu 14.10) at work works properly.

WinXP 32bit at home gives me (-0.78, -0.78) on X and Y axes when nothing is pressed.

Linux 32bit on laptop and Linux 64bit (Ubuntu 14.10) at home got same results on following sequence:
1. I connect joystick
2. Run application
3. Get axes positions (-100, -100) on X and Y
4. Pressing D-pad on X and Y
5. Releasing D-pad and got (0, 0)
6. Run application again
7. Get axes positions (0, 0) on X and Y

So the initial state is wrong.

Can anyone help me, what could be the reason of this strange behavior?  :-\

Tested on this:

#include <SFML/Window.hpp>
#include <stdio.h>
#include <unistd.h>

int main() {
        sf::Window window(sf::VideoMode(800, 600), "My window");

        while (window.isOpen()) {
                sf::Event event;

                while (window.pollEvent(event)) {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }

                printf("(%3.2f, %3.2f)\n", sf::Joystick::getAxisPosition(0, sf::Joystick::X),
                                           sf::Joystick::getAxisPosition(0, sf::Joystick::Y));
        }
        return 0;
}
 

gcc main.cpp -o test -lsfml-window -lsfml-system -lstdc++

12
Feature requests / sf::RectangleShape(sf::FloatRect) constructor
« on: April 14, 2015, 05:36:44 pm »
I think it will be useful to make a RectangleShape constructor with FloatRect argument ;)

position = sf::Vector2f(left, top);
size = sf::Vector2f(width, height);

13
General discussions / Congratilations with Programmers day!
« on: September 13, 2014, 01:11:59 pm »
Let me congrat all of you with Programmer's day!!!  ;D Have fun while coding! And let me wish you all good wishes!  :P

14
SFML projects / Image Palette Applier
« on: September 09, 2014, 10:15:15 pm »
Good day!

For some time I was looking for the way to apply color palette to specific image (to make image use only colors, defined in palette).

GIMP can make indexed image, but there's 2 main problems:
  • Limitation of 256 colors
  • Alpha channel reset

Well, I decided to make own implementation (it's not finished yet, but workable).

Current features:
  • Able to choose what coordinates to use RGB or HSV
  • Support for GPL and TXT (exported from GIMP) palettes

For now it rewrites original file. Maybe I'll add an option later.
Btw, my tool much slower than GIMP, but it was 4 times slower before I've implemented cache  ;D

https://github.com/achpile/sfml-paletter

Well, screenshots, of course  :D
For all of the manipulations I used 'Cranes' palette from GIMP.

PS: maybe it's a bad example (palette not great to use on this image). So... The only way to find out it's usability is to check it out  ;)

Original:


GIMP indexing result:


RGB space:


HSV space:

15
Feature requests / sf::Rect extension
« on: August 28, 2014, 01:04:53 pm »
I think it will be useful functions to get position, size and (position + size) of the rectangle class instead of using everywhere in the code sf::Vector2(rect.left, rect.top) use simple rect.getPosition().

I don't want to make a pull request, 'cause some my things (like doxygen comments and formatting) may differ of what supposed to be. So here's a simple patch. And I don't know, how to name function returning (position + size) :D

diff --git a/include/SFML/Graphics/Rect.hpp b/include/SFML/Graphics/Rect.hpp
index 2880722..d565b5e 100644
--- a/include/SFML/Graphics/Rect.hpp
+++ b/include/SFML/Graphics/Rect.hpp
@@ -146,6 +146,36 @@ public :
     bool intersects(const Rect<T>& rectangle, Rect<T>& intersection) const;
 
     ////////////////////////////////////////////////////////////
+    /// \brief Get the position of the rectangle
+    ///
+    /// This returns the position of the rectangle
+    ///
+    /// \return Rectangle position
+    ///
+    ////////////////////////////////////////////////////////////
+    Vector2<T> getPosition();
+
+    ////////////////////////////////////////////////////////////
+    /// \brief Get the size of the rectangle
+    ///
+    /// This returns the size of the rectangle
+    ///
+    /// \return Rectangle size
+    ///
+    ////////////////////////////////////////////////////////////
+    Vector2<T> getSize();
+
+    ////////////////////////////////////////////////////////////
+    /// \brief Get the position of the far point of the rectangle
+    ///
+    /// This returns the position of the far point of the rectangle
+    ///
+    /// \return Rectangle position of the far point
+    ///
+    ////////////////////////////////////////////////////////////
+    Vector2<T> getPositionFar();
+
+    ////////////////////////////////////////////////////////////
     // Member data
     ////////////////////////////////////////////////////////////
     T left;   ///< Left coordinate of the rectangle
diff --git a/include/SFML/Graphics/Rect.inl b/include/SFML/Graphics/Rect.inl
index 4a92397..779c904 100644
--- a/include/SFML/Graphics/Rect.inl
+++ b/include/SFML/Graphics/Rect.inl
@@ -157,3 +157,27 @@ inline bool operator !=(const Rect<T>& left, const Rect<T>& right)
 {
     return !(left == right);
 }
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+Vector2<T> Rect<T>::getPosition()
+{
+    return Vector2<T>(left, top);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+Vector2<T> Rect<T>::getSize()
+{
+    return Vector2<T>(width, height);
+}
+
+
+////////////////////////////////////////////////////////////
+template <typename T>
+Vector2<T> Rect<T>::getPositionFar()
+{
+    return Vector2<T>(static_cast<T>(left + width), static_cast<T>(top + height));
+}
 

Pages: [1] 2 Next
anything