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.


Topics - Voroz

Pages: [1] 2
1
SFML projects / Chess
« on: August 08, 2016, 03:12:37 pm »
Hi!
Thought i'd share my most recent project that i made during 2 days. I started making it because i thought it would be interesting to create a chess AI. I managed to make one, it's not that great but for a horrible opponent like myself it's pretty hard :).



Tell me what you think, and if you can manage to beat it. (there is no end screen right now, you'll just have to know that you won"

for windows: https://dl.dropboxusercontent.com/u/150244750/Chess.rar

2
SFML projects / The Possible Game
« on: April 14, 2016, 08:07:08 pm »
Hi!

I just want to share what i'm currently making with SFML, as a university project.
Here is a small video of the game, tell me what you think :):

edit: Also, i should mention that i'm using my own physics system for this game. That's what took most of the time to make.

edit2: I also haven't gotten around to making a bigger map since it's really tedious placing the boxes at good locations. I need to make a level editor i think.

3
General / sf::Clock strangler of internets
« on: November 01, 2015, 01:12:35 pm »
Hi. I've been working on a network game, and after i implemented box2d on the server i noticed i was starting to get lag, so after a while of searching for bugs i tried running broadband test before and after i started the server.
Before i had 97/97 mbit up down, and after i started the server i had about 10-15 mbit down, and 20 up.

I was thinking it was a networking issue, but i commented all my code out until this was left:

#include <SFML/System.hpp>


int main(){
    sf::Clock clock;
    while (1){
        clock.restart();
    }
return 0;
}

This code takes out 80-90% of my internet. clock.getElapsedTime(); also does it. I really need to use the timer for my application though but since it's a network app, it makes it lag.

Anyone else experience the same issue?

edit: Also this will cause the same issue:
int main(){
    while (1){
        sf::Clock clock;
    }
return 0;
}

4
Network / sf::socket::Status returning sf::Socket::Error
« on: October 29, 2015, 09:02:00 pm »
Hi. I've been trying to get this networking to work for several days now. I started out with a bit more complex project, but did a new project now to see if i could replicate the issue with a minimal example.

If i debug the server and join a client, the socket will work for the first "frame" or step through the program. After that it will stop working and return sf::Socket::Error.

This is my code:
https://gist.github.com/anonymous/508a862ff47f41e1805f


Thanks!

Edit: I didn't store the socket properly, although this was just for this smaller example. My other code still doesn't work.

5
General / Help with some trig math
« on: October 24, 2015, 11:34:47 pm »
Hi. I'm trying to render some stuff faster with help of a vertexarray. Problem is that when i get the 4 vertexes of my sf::RectangleShapes i get the positions without rotation applied. Also the positions are given without accounting for my setOrigin. So i did some trigonometry to try and get what i wanted: This is the code:

class cVertexRendering{
    public:
    void addRect(sf::RectangleShape Rect){
        for (int i = 0; i < Rect.getPointCount(); i++){
            float x = Rect.getPoint(i).x - Rect.getSize().x/2;
            float y = Rect.getPoint(i).y - Rect.getSize().y/2;
            float length = sqrt(powf(x, 2) + powf(y, 2));

            float actualVertexAngle;
            actualVertexAngle = atan2f(y, x);
            //Convert to 0-360 from -180 +180
            if (actualVertexAngle < 0){
                actualVertexAngle += 2*PI;
            }
            //Add rect rotation
            actualVertexAngle += DEGTORAD*Rect.getRotation();

            sf::Vector2f actualVertexPosition;
            actualVertexPosition.x = length*cosf(actualVertexAngle);
            actualVertexPosition.y = length*sinf(actualVertexAngle);
            sf::Vertex vertex = sf::Vertex(sf::Vector2f(Rect.getPosition().x + actualVertexPosition.x,
                                                        Rect.getPosition().y + actualVertexPosition.y),
                                                        Rect.getFillColor());
            vertexArray.append(vertex);
        }
    };
    sf::VertexArray getVertexArray(){
        return vertexArray;
    }
    void clear(){
        vertexArray.clear();
    }
    private:
    sf::VertexArray vertexArray = sf::VertexArray(sf::Quads);
}vertexRendering;

What happens is that i get almost a triangular shape instead of the rectangle shape that's supposed to happen. Also the rotation doesn't match. Any idea where i go wrong? been looking at this for hours.

6
General / Need some help optimizing rendering speed.
« on: October 14, 2015, 07:47:58 pm »
So i created a class on my own to attempt to reduce batch calls to optimize speed of my application. This is the class:
(click to show/hide)

I noticed that i don't gain any speed by doing this since i already separate most of my textures when drawing them. It seems that to gain speed i should reduce draw calls since i quite rarely swap texture in comparison to calling draw.
What can i do to optimize my rendering? This is my rendering code. Replace renderList.add() with app.draw(), and that's what i started with before i made the class:
(click to show/hide)

Just interested in how you're supposed to do the rendering because what i have i've mostly come up with on my own.

7
General / problems with c++14
« on: October 11, 2015, 12:55:06 pm »
Hi!
I just upgraded to mingw 5.2 and trying to use LTBL2 which is using c++14 features, but when i try to compile i get "'make_unique' is not a member of 'std'"

I created a flag -std=c++14 in project build options -> compiler flags, and it doesn't complain about it. I tried changing to -std=c++16, and then it wouldn't run, so it does recognize the command.
So why do i still get this error?

Thanks.

8
General / Too much screen tearing
« on: August 04, 2015, 05:17:10 pm »
Hi.

I'm having some trouble with input lag with vsync on. If i disable vsync my mouse sprite is much faster and not so sluggish, but i get aloooot of screen tearing. I will have a constant huge line covering 10% of my screen height moving up or down slowly. The higher fps i get the thinner the line will be, but it's always there, even at 1300 fps.

I don't get tearing problems in other games if i get high enough fps so i'm not sure what the problem is. I've also tried using setFramerateLimit to see if i can get a certain fps with less tearing, but setFramerateLimit just picks set FPS values that aren't really even close to what i told it to pick. For example one fps is 200, next is 250 no matter what i type in between.

Thanks for your time.

9
Feature requests / Hardware cursor
« on: May 01, 2014, 04:42:19 pm »
I'd like to see a hardware cursor since if you use a sprite to display the cursor then it's too unresponsive even at 60 fps.
I know it's been asked for before but i don't want to revive an old thread and i saw that Laurent thinks it's a very low priority but i think it's quite an important feature for most games that uses a mouse.

10
SFML projects / SFML Test game
« on: April 24, 2014, 09:20:06 pm »
Hi.

I've been working on and off on a game mostly to try and learn something and have fun. I'm not sure what sort of game i'd like it to become tbh and i'll probably try to learn some more programming before i finish it.

Anyway i just wanted to post it here to show what i've done so far with SFML :).

if you move down a bit from where you spawn in the game there are some box2d boxes and at coordinates 8000,2000 there are some enemies also made in box2d. They wont hurt you though, just follow you.

Tell me if you have any ideas of how i could make something of this that doesn't take too much time for 1 person, thanks for your time.

https://dl.dropboxusercontent.com/u/150244750/Release.rar

Make sure you are using a 1920*1080 or 1680*1050 screen and chose the corresponding exe file or it won't run as it should. Also i've tested this app on 1680*1050 and have only had someone else test it on a 1920*1080 screen (he said it ran normally on that resolution) so i can't be sure if it runs as it should on that higher resolution.

edit: Also i'm sorry about the filesize. Almost exclusively the big background image taking up that filesize. It's 75 mb because of the grass that i made in maya.

11
General / Create unlimited amount of bullets
« on: January 02, 2014, 06:34:18 pm »
Hello.
I previously had a static array where i entered the max amount of bullets as the size of array, for example 100. But i guess this isn't such a good approach for many things where the array size varies, so i heard vectors were a good option instead of arrays because you don't need to memory manage them like with a dynamic array.

But now i need some help in how i'm supposed to use the vector. This is what i have so far. it crashes when it goes into the function newBullet. The problem right now is that the bullet will not be affected by the box2d world. Gravity for example wont affect it.



struct sBox{
    b2BodyDef myBodyDef;
    b2Body* body;
    b2PolygonShape boxShape;
    b2FixtureDef boxFixtureDef;
    sf::RectangleShape Rect;
};

struct sBullet{
    int airTime;
    sf::Vector2f targetVector;
    float toTargetAngle;
    float speed;
    sBox box;
    sf::Sprite Sprite;
};

struct sCharacter{
    std::vector<sBullet> bullet;
    sf::Vector2f targetVector;
    float toTargetAngle;
    int castTime;
    float degreeAngle;;
    int bulletCooldown;
    };
sCharacter character;

void newBullet(sCharacter *character, int PPM, b2World *world, sf::Texture *Texture, sf::Vector2i worldMouseClick, sf::Vector2f position, sf::Vector2f boxSize){
        sBullet bullet;
        character->bullet.push_back(bullet); //+1 to array

        //Calculate bullet path and angle
        character->bullet.back().targetVector.x = worldMouseClick.x - position.x;
        character->bullet.back().targetVector.y = worldMouseClick.y - position.y;
        character->bullet.back().toTargetAngle = atan2(character->bullet.back().targetVector.y, character->bullet.back().targetVector.x);

        //Bullet duration and cooldown
        character->bullet.back().airTime = 500;
        character->bulletCooldown = 20;

        //Set box2d value + spawn body
        character->bullet.back().box.myBodyDef.type = b2_kinematicBody; //this will be a kinematic body
        character->bullet.back().box.myBodyDef.position.Set(position.x/PPM, position.y/PPM); //set the starting position
        character->bullet.back().box.myBodyDef.angle = 0; //set the starting angle
        character->bullet.back().box.body = world->CreateBody(&character->bullet.back().box.myBodyDef);
        character->bullet.back().box.boxShape.SetAsBox(boxSize.x/PPM/2, boxSize.y/PPM/2);
        character->bullet.back().box.boxFixtureDef.shape = &character->bullet.back().box.boxShape;
        character->bullet.back().box.boxFixtureDef.density = 1;
        character->bullet.back().box.body->CreateFixture(&character->bullet.back().box.boxFixtureDef);

        character->bullet.back().box.body->SetActive(true);

        //Set bullet sprite
        character->bullet.back().Sprite.setTexture(Texture[9]);
        character->bullet.back().Sprite.setOrigin(character->bullet.back().Sprite.getLocalBounds().width -20, character->bullet.back().Sprite.getLocalBounds().height / 2);
};

int main(int argc, char** argv){

b2Vec2 gravity(0, 0); //normal earth gravity, 9.8 m/s/s straight down!
b2World* world = new b2World(gravity);
world->SetAllowSleeping(true);


//Bullet Cast time
if (character.castTime >= 0){
    character.castTime -= 1;
}
//Bullet Cooldown
if (character.bulletCooldown > 0){
character.bulletCooldown -= 1;
}

//Start bullet cast
if (mouseOnInventory == false && itemMousePos == -1 && itemOnMouse == -1 && leftButtonDown == 1 && character.castTime == -1 && character.bulletCooldown == 0 && character.currentMana >= character.bullet[0].manaCost){
            worldMouseClick = worldMouse; //Save click pos
            character.castTime = 20;
            character.currentMana -= character.bullet[0].manaCost;
            //Set only character angle
            character.targetVector.x = worldMouseClick.x - Character.getPosition().x;
            character.targetVector.y = worldMouseClick.y - Character.getPosition().y;
            character.toTargetAngle = atan2(character.targetVector.y, character.targetVector.x);
            character.degreeAngle = character.toTargetAngle * 180 / PI;
}

//Fire bullet
if (character.castTime == 0){
            newBullet(&character, PPM, world, Texture, worldMouseClick, Character.getPosition(), sf::Vector2f(40, 40));
            character.bullet.back().box.body->SetTransform(b2Vec2(Character.getPosition().x/PPM, Character.getPosition().y/PPM), character.bullet.back().toTargetAngle);
}
//Set bullet pos
for (int i = 0; i < character.bullet.size(); i++){
        character.bullet[i].box.body->SetLinearVelocity(b2Vec2(cos(character.bullet[i].toTargetAngle)*character.bullet[0].speed, sin(character.bullet[i].toTargetAngle)*character.bullet[0].speed));
}


//Remove bullet after a certain time
for (int i = 0; i < character.bullet.size(); i++){
    if (character.bullet[i].airTime > 0)
        character.bullet[i].airTime -= 1;

    else{
        character.bullet[i].box.body->SetActive(false);
        character.bullet.erase(character.bullet.begin() + i-1);
    }
}

//Box2d
float32 timeStep = 1/60.0;      //the length of time passed to simulate (seconds)
int32 velocityIterations = 10;   //how strongly to correct velocity
int32 positionIterations = 6;   //how strongly to correct position
//Update world. This needs to come after you set positions and before you try to get current positions values.
world->Step(timeStep, velocityIterations, positionIterations);

//Set positon of sprites.
for (int i = 0; i < character.bullet.size(); i++){
character.bullet[i].Sprite.setPosition(character.bullet[i].box.body->GetPosition().x*PPM, character.bullet[i].box.body->GetPosition().y*PPM);
character.bullet[i].Sprite.setRotation(character.bullet[i].box.body->GetAngle()*RADTODEG);
}
}

12
General / main.cpp file suddenly empty but still has file size 29kb
« on: August 10, 2012, 08:25:31 am »
Hi. It was quite some time i did any programming but i decided to test my small game, which holds pretty much all my programming skills and the collision type i came up with etc. It's almost all that i've done so it sucks to have it disappear. I even saved the project on a USB and in my computer, but the main.cpp is empty in both places. I have a few other smaller test programs with 5-8 kb main.cpp files and they work fine. But in this only important project it's gone.

The file was last changed 03/17 it says, i'm not sure if i did any programming then or not. What gives me a bit of hope still is that it's 29kb, so it can't be empty. Does anyone know what i can do? I'll post the file here so you can check for yourselves.



[attachment deleted by admin]

13
General / homing missile
« on: August 08, 2011, 10:01:35 pm »
Hi. I'm attempting to make a homing missile, and i managed to get it work quite well except for one thing. So far i have only done the rotation of the missile but the problem is that since i am using atan2 to check for the angle of the missile to the target, when the transition comes from 3.14 to -3.14 the missile will start rotating the other way.

Code: [Select]
missile.targetVectorX = mouseX - Missile.GetPosition().x;
missile.targetVectorY = mouseY - Missile.GetPosition().y;

missile.worldAngle = Missile.GetRotation() * PI / 180;
missile.atanAngle = atan2(cos(missile.worldAngle), sin(missile.worldAngle));
missile.distanceToTarget = sqrt(missile.targetVectorX * missile.targetVectorX + missile.targetVectorY * missile.targetVectorY);
missile.toTargetAngle = atan2(missile.targetVectorY, missile.targetVectorX);
if (missile.atanAngle < missile.toTargetAngle)
    missile.rotation  -= 1;
else
missile.rotation += 1;

Missile.SetRotation(missile.rotation);


Any ideas? maybe a possibility to get a radian 6.28 no minus instead of atan2 on the toTargetAngle?

Thx.

14
General / Rotation Formula
« on: August 07, 2011, 07:30:00 pm »
Hi. I have been trying for many hours to get this to work.
I want to rotate a door together with a room, so it stays on the same wall when the room rotates. I did try to set center of the door on the same location as setcenter of the room is (middle), and that worked. But then the doors x and y will be missplaced.

I would like to know of a formula that can rotate the door around a point based on what angle the room has. I have only done Math A and B so i'm no math proffessor, maybe someone else is and can help me by explaining it well? :).
Thx

15
General / Anyone need automatisation for putting sprites in 1 file?
« on: April 15, 2010, 04:40:57 am »
Hi. I was exporting a 3d character to png files. 26 frames in 8 directions so 208 images that i needed to put in 1 image file. I sat for hours and hours with it, every image needs to be on the exact correct pixel, or the character will seem to change position when updating frame. And i thought that i don't wanna do this for every animation i create, for 8 different directions, so i am making a program that is automating this process. You just need to enter a few values and everything is handled automatically. The images don't need to be the correct size from the start or anything.

Anyway is anyone else annoyed with this and want the program? (it's for paint.net only)


Edit: I should probably have posted this in general discussions.

Pages: [1] 2
anything