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

Pages: [1]
1
General / Re: Should I start off this complex?
« on: October 18, 2015, 12:19:50 pm »
This is all really useful, I'll take this all into account when working on projects in the future. thanks :)

2
General / Should I start off this complex?
« on: October 17, 2015, 02:51:27 pm »
After I made my first proper...well thing using SFML (https://github.com/Crdl-Pls/Pang), I wanted to see if I could work on my code management a little bit, and work a bit more with the features that C++ has to offer, while getting some tips from the SFML books.

https://github.com/Crdl-Pls/Asteroods
This is what I have so far. I have a very bare-bones entity manager class handling the creation and destruction of entities. I want a texture manager class too, to manage the textures that each entity has. Now looking forward, I think I can do it, but it will take me a bit of time to get right. Am I wasting my time making this overly complex for my second real project using SFML, or will I be better off for it in the long run?

Any tips, based on my code as it stands or for the future, would be a massive help also.

3
Whoa, this is great. Thanks guys, I'm gonna take all of this on board.

4
This is exactly what I meant. Thanks :D

Sorry about the terminology thing, I'm new to this whole thing.

5
I'm trying to make a simple program, with two 'views' that look different (different shapes on each one to tell them apart) not really for a practical reason, just to get to know SFML. However I seem to hit a brick wall. This is what I have so far:
//main.cpp
#include <iostream>
#include <SFML/Graphics.hpp>
#include "Button.h"
#include "Constants.h"

sf::RenderWindow window(sf::VideoMode(windowX, windowY), "SFML works!");

void MainMenu()
{
        Button buttonQuit;
        buttonQuit.initButton(50,60,sf::Color::Blue);
        Button buttonStart;
        buttonStart.initButton(300, 300, sf::Color::Green);
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }              
                window.clear(sf::Color(153,204,255,0));
                window.draw(buttonQuit.button);
                window.draw(buttonStart.button);
                window.display();
        }
}
int main()
{
        MainMenu();
}

//button.h
#ifndef BUTTON_H
#define BUTTON_H
#include <SFML/Graphics.hpp>

class Button
{
public:
        sf::RectangleShape button;
        void initButton(float posX, float posY, sf::Color color, float sizeX = 200, float sizeY = 80)
        {
                button.setPosition(sf::Vector2f(posX, posY));
                button.setSize(sf::Vector2f(sizeX, sizeY));
                button.setFillColor(color);
        }
};
#endif

//constants.h
#ifndef CONSTANTS_H
#define CONSTANTS_H

const int windowX = 1280;
const int windowY = 720;

#endif

I know I shouldn't have the game loop inside of the MainMenu() function, but I have no idea how else I should be doing this. When I try to add another function similar to MainMenu() and go between them on mouse click, it crashes. How can I set this up so that it will work, be efficient (as in, only one game loop) and ensure that the code is as clean as possible? (My main problem is that if I do everything in a separate function, that is called by the main function, I would need to declare everything in a header or define everything in place to be able to use it, at least I think. I'm still new-ish to this).

Thanks :)

TLDR: How do I create two distinct 'views'  and be able to change between them.

Pages: [1]
anything