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

Pages: [1] 2
1
Graphics / Re: Sf::Text goes to left
« on: November 04, 2017, 05:42:57 pm »
Sorry for late reply, Thanks for the help but the only problem was that I delete the X pos of the text by sf::Sprite::getGlobalBounds()  ;D

2
Graphics / Sf::Text goes to left
« on: October 29, 2017, 08:41:44 pm »
Hello guys!
I have a problem when it comes to the text. The text goes to the left side when I type longer
sentences and I want it to the right side instead.
sf::Text::setPosition(this->window->getSize().x / 2 - sf::Text::getGlobalBounds().width / 2 - 30, this->window->getSize().y - sf::Sprite::getGlobalBounds().height - 280);


If you see the picture you will probably understand what the problem is :P

3
General discussions / IOS support?
« on: March 19, 2017, 08:47:37 pm »
Hello, I have started to think about to create a mobile game. I have read some old posts from 2013 and noticed that sfml had started to working on the ios function. I dont get it but have the sfml team fix so you can start to develop game to the ios?

4
SFML projects / Jump & Slide
« on: March 06, 2017, 09:52:07 pm »
Hello guys, this is my first project with SFML and im very proud of it:P
The game is a Jump & Slide game and are inspired by the game geometry dash.

Controls :
Run with the left and right arrow keys
Jump with space
Slide with the down arrow key
Join a room with the up arrow key

Game includes:
4 diffrent levels
Charachter design
Level system
2 Spells

Download the game : http://www.mediafire.com/file/6oa23tnqalqcyc8/Jump+%26+Slide++version+1.0.rar

Some screenshots



5
Graphics / Re: Event, is it a diffrent between Debug and Release mode
« on: March 06, 2017, 06:54:32 pm »
Thanks!, Got It work now!! ;D

6
Graphics / Re: Event, is it a diffrent between Debug and Release mode
« on: March 05, 2017, 02:37:00 pm »
Okay, I have fix a complete try program


Main function
#include <SFML\Graphics.hpp>
#include "game_state.h"
#include "main_menu.h"

game_state coreState;

int main(int argc, char* argv[])
{
        sf::RenderWindow window(sf::VideoMode(1280, 768), "Test", sf::Style::Close);

        window.setVerticalSyncEnabled(true);
        coreState.setWindow(&window);
        coreState.SetState(new main_menu());

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        switch (event.type)
                        {
                        case sf::Event::Closed:
                                window.close();
                                break;
                        }
                }
                window.clear();

                coreState.Update();
                coreState.Rendere();

                window.display();
        }
        return 0;
}

 

game_State.h
#pragma once
#include "SFML\Graphics.hpp"
#include "SFML\Audio.hpp"
class tiny_state {
public:
        virtual void Initialize(sf::RenderWindow *window)
        {
        }
        virtual void Update(sf::RenderWindow *window)
        {
        }
        virtual void Render(sf::RenderWindow *window)
        {
        }
        virtual void Destroy(sf::RenderWindow *window)
        {
        }
};
class game_state {
public:
        game_state()
        {
                this->state = NULL;
        }
        void setWindow(sf::RenderWindow *window)
        {
                this->window = window;

        }
        void SetState(tiny_state *state)
        {
                if (this->state != NULL)
                {
                        this->state->Destroy(this->window);

                }
                this->state = state;
                if (this->state != NULL) {
                        this->state->Initialize(this->window);
                }
        }
        void Update()
        {
                if (this->state != NULL)
                {
                        this->state->Update(this->window);
                }

        }
        void Rendere()
        {
                if (this->state != NULL)
                {
                        this->state->Render(this->window);
                }
        }
private:
        sf::RenderWindow *window;
        tiny_state *state;
};
extern game_state coreState;
 

Main_menu.h
#pragma once
#include "game_state.h"

class main_menu : public tiny_state
{
public:
        void Initialize(sf::RenderWindow *window);
        void Update(sf::RenderWindow *window);
        void Render(sf::RenderWindow *window);
        void Destroy(sf::RenderWindow *window);
private:
        sf::Font font;
        sf::String s1;
        sf::Text characterName;
};
 

Main_menu.cpp
#include "main_menu.h"
#include <string>

void main_menu::Initialize(sf::RenderWindow *window)
{
        this->font.loadFromFile("Morris.ttf");
        this->characterName.setString(s1);
        this->characterName.setFont(this->font);
        this->characterName.setCharacterSize(15U);
        this->characterName.setPosition(500, 500);
}
void main_menu::Update(sf::RenderWindow *window)
{
        sf::Event event;
        while (window->pollEvent(event))
        {
                if (event.type == sf::Event::TextEntered)
                {

                        if (event.text.unicode == '\b')
                        {
                                if (s1.getSize() > 0)
                                        s1.erase(s1.getSize() - 1, 1);
                        }
                        else
                        {
                                if (s1.getSize() < 10)
                                {
                                        s1 += static_cast<char>(event.text.unicode);
                                        if (event.text.unicode < 128)
                                        {
                                                this->characterName.setString(s1);
                                        }
                                }
                        }
                }
        }
        this->characterName.setString(s1);
}

void main_menu::Render(sf::RenderWindow *window)
{
        window->draw(this->characterName);
}
void main_menu::Destroy(sf::RenderWindow *window)
{

}
 

7
Graphics / Re: Event, is it a diffrent between Debug and Release mode
« on: March 04, 2017, 07:33:05 pm »
Okay, I will try to fix a minimal exampel and then try to find the issue, If I dont find It i will come back!  :P

8
Graphics / Re: Event, is it a diffrent between Debug and Release mode
« on: March 04, 2017, 06:21:15 pm »
I dont know how to send a complete code of this problem. I have made so I have diffrent states and then in this state I called a update function in main.cpp between window.clear and window.display. Then I have a window pointer that comes from the main.cpp I use sf::event with.

9
Graphics / Re: Event, is it a diffrent between Debug and Release mode
« on: March 04, 2017, 06:06:59 pm »
Okay, here is a minimal code

sf::Event event;
        while (window->pollEvent(event))
        {
                if (event.type == sf::Event::TextEntered)
                {

                       

                                if (event.text.unicode == '\b')
                                {
                                        if (s1.getSize() > 0)
                                                s1.erase(s1.getSize() - 1, 1);
                                }
                                else
                                {
                                        if (s1.getSize() < 10)
                                        {
                                                s1 += static_cast<char>(event.text.unicode);
                                                if (event.text.unicode < 128)
                                                {
                                                        this->characterName.setString(s1);
                                                }
                                        }
                                }
                }
        }
 

10
Graphics / Event, is it a diffrent between Debug and Release mode
« on: March 04, 2017, 03:19:05 pm »
Hello, I started to wondering if its a diffrent between Debug and Release when it comes to Sf::Event. When I run my program in debug mode the events are very fast(Like when I type a letter it will pop up fast). But in Release mode the events are so slow so I cant type a letter, I moust spam my keyboard around 5 - 10 seconds befor it pop up.
I wonder why it is so.

11
Graphics / Re: Why does it delete the last charachter
« on: March 02, 2017, 10:00:31 pm »
Thank you for the help, It work now!

12
Graphics / Re: Why does it delete the last charachter
« on: March 02, 2017, 06:55:11 pm »
Hey, I can not use .pop_back with s1 insted of s1.erase(s1.getSize() - 1, 1). Have I done something wrong?
I think you only can use pop_back if its a std::string

13
Graphics / Why does it delete the last charachter
« on: March 02, 2017, 05:46:32 pm »
Hello, I always get "out of range" when I delete a the invisble charachter. I dont know why I run into this error. I have search and include the s1.getSize so I can see how big the string is but I dosent seem to work.

S1 is a SF::string
CharachterName is a SF::Text


if (event.type == sf::Event::TextEntered)
                {
                                if (event.text.unicode == '\b' && s1.getSize() > 0)
                                {
                                        s1.erase(s1.getSize() - 1, 1);
                                        this->characterName->setString(s1);
                                }
                       
               
                                if (event.text.unicode < 128)
                                {
                                        s1 += static_cast<char>(event.text.unicode);
                                }              
                        else
                        {
                        }
                        break;
                }
 

14
Network / Send player Information through packets
« on: February 10, 2017, 09:48:52 pm »
Hey :D!

When I was working to send the player information (movement and animation) I ended up like, how should I send all these kind of stuff to the server and then send it to the other client on the server.
I rellay nedd some tips how I can send this kind of information to the server.
Should I try to send the whole main_player() class through a packet?

I should be were pleasent if I can get some advice, thanks!

15
Network / Re: Packets send wrong information to the server?.
« on: February 08, 2017, 03:44:02 pm »
It returns "Error" in the console?, or have I missed a step to send the packet?

Pages: [1] 2
anything