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

Pages: [1]
1
General / Re: C++: Advice for creating a 'screen' and 'object' system
« on: April 12, 2013, 04:44:45 pm »
:'(

Instead of attempting something large like the project you have in-mind, why don't you start off small? Create an entity class, play around with it and understand how C++ does then. Then from there you will have enough knowledge to approach the idea in your OP.

2
General / Re: C++: Advice for creating a 'screen' and 'object' system
« on: April 12, 2013, 03:39:51 pm »
I'm relatively new to C++, but I think I know about 90-95% of it.

The amount of questions you've asked this week proves this statement is incorrect.

3
General / Re: C++: Advice for creating a 'screen' and 'object' system
« on: April 12, 2013, 02:36:06 pm »
Basically yeah, just I would make it a bit more simpler, for retards like myself.  ;D

I don't you can make it any more simple than it already is, that is a very very basic example.

4
General / Re: C++: Advice for creating a 'screen' and 'object' system
« on: April 12, 2013, 04:09:43 am »
Not really sure why you'd want to do that but its possible, it might be;

   
        GameState screenCreate(sf::String, sf::Vector2f size, sf::color)
        {
                newState = gamestate;

                newState.setTitle(String);
                newState.setSize(size);
                newState.setcolour(colour);

                return newstate;
        }

        Entity newEntity((sf::String, sf::Vector2f size, sf::color)
        {
                newEntity = Entity;

                newEntity.setTitle(String);
                newEntity.setSize(size);
                newEntity.setcolour(colour);
        }

        GameState::addEntity(Entity newEntity)
        {
                entityList.push_front(newEntity));
        }

        gamestate tempState = screenCreate("New Window", sf::vector2f(100,100), sf::colour:green);

        entity tempEntity = newEntity("New Entity", sf::vector2f(50,50), sf::colour::orange);

        tempState.addEntity(tempEntity);
       

Is that what you'd want too do?

Inside each gameState might be this;

std::list<Entity*> entityList;

5
General / Re: C++: Advice for creating a 'screen' and 'object' system
« on: April 12, 2013, 02:45:25 am »
But I do understand OOP. I just don't understand the syntax to store objects in the list and have that list/screen-class then 'create' that object as an instance, and then how to safely destroy everything.

Surely it can't be that hard..

It may not be hard to do but it'd require a lot of explaining and code examples which many people don't have the time to provide.

After reading the OP, I might be wrong with this, I believe you want to create a state manager like system to handle changing from state to state. The one that eXpl0it3r created and linked in his post is a perfect example. You have a superclass that will contain all the methods and variables required for each state. Such as, draw, update, init etc.

You then can create child classes of the superclass and create override methods of each method you might require. Inside these child classes would be information related to each state, entites, logic etc.

You could then do for example.

MainGame game;
MainMenu menu;

statemanager.addState(game);
statemanager.addState(menu);

stateManager.changeState(GameState::type::MainGame);
 

I'm no where near the best C++ programmer on this website but I hope my explanation helps you understand what you need to create. If it still doesn't, go look at the example eXpl0it3r posted.

6
Is my code that terrible that no one wants to even attempt helping me?

7
After lots of failing, finally got it uploaded to git.

Question, I'm going to change all constructors in the project to use initialization lists but I have an issue.

If the super classes constructor is as follows;

Entity::Entity(GameState *state)
        :_isLoaded(false), _state(state), alive(true)
{

}

What do I do a child classes constructor? I've attempted lots of different variations but none seem to be working, this was the closest I got to expecting it too work.

Player::Player(GameState *state)
        : score(0), health(100), xp(0), rank(0), bulletSpeed(600),triShot(false),rapidFire(false)
        : Entity(state) : name(entityPlayer), collidable(true)

I originally had name and collidable as part of the player constructor and it errored but then was curious at, because they're part of the entity class if they should go with that? Either way nothing worked and it left me back at the beginning of the error.

SLIGHT FIX:

Player::Player(GameState *state)
        : Entity(state), score(0), health(100), xp(0), rank(0), bulletSpeed(600),triShot(false),rapidFire(false),_colour(sf::Color(128,255,86,255))
{

Complies without error but I'm unable to include the boolean "collidable" or the enum "name" as they appear to error no matter where I put them, So how does one include variables that are in the superclass using initialization lists?

8
After learning SFML and playing around with it for just over a year, I've been making my own mini engine for me to use to make basic games. Even though it works well, I feel its extremely poorly programmed, I see a lot of people saying that manual memory allocation (= new object) is terrible and you should never use it.

I use it ALOT, so I feel its about the right time to change my ways and learn to program correctly. I feel as though uploading the code I've created so far would be the smart option so you can all see how and where I've gone wrong but I'm not really sure the best method.

Link to my git: https://github.com/ChrisMelling/basicGame

The way I went about the design was. Each GameState knows of the application class and methods to access its information then each Entity knows about the state it was created in, so therefore the entities are able to access practically all methods in the game, all the back to the Application class.

This seem'd to make sense in my head but you're all about too rip it to shreds but I welcome it with open learning arms.

Edit: I fear I'm going to be shouted at a lot for doing this, but how terrible is it to use reinterpret_cast/dymanic_cast?

9
SFML projects / Re: First sfml gave, very basic!
« on: January 29, 2013, 11:22:14 pm »
Nice =)

You should block the player when he tries to get out of the frame, I lost myself :p
Add an HUD would be indeed useful, we cannot know how much life remains

The querty controls are not very handy for a frenc like me, that's hard to stay alive :p

I attempted to stop the player running off but I'm not great at collision logic, so if someone could help me with that I'd be much appreciated.

10
SFML projects / First sfml gave, very basic!
« on: January 29, 2013, 09:44:19 pm »
Good evening,

Thought It was about time I showed some people the extremely basic game I've been working on. It was really a learning experience of how to create the framework around a game instead of aiming to create a game.

I guess the main thing I learn't was to create an entityManager to house all the entities in the game instead of having bits and bobs everywhere. Still not sure If I implemented it as correctly as I could have but I'll get up a github later so you lovely people can rip my code apart and tell me how terrible it is.

Controls:
  • Left mouse to fire
  • WASD to control the player
Objective:

The idea of the game is that you have to dodge/attack enemies, after 15 seconds the wave resets and the next week the enemies will be greater in number and travel slightly faster.

Red enemies spawn randomly and will seek you out in an attempt to destroy you.
Blue enemies will all spawn at the start of a wave but will travel randomly around.

Todo:
  • Add in more interesting enemies
  • Create a nice looking hud
  • Make the main menu and game over states nicer looking
  • Add sound

Download

http://puu.sh/1UxZG

11
Network / Re: Sending information to a Mysql table
« on: January 29, 2013, 09:22:51 pm »
Well, As I've no idea how'd I go about doing it I wasn't sure if sfml was capable of doing it with its provided networking libraries. So I was just after some help with it, but if its the wrong place for this kinda of topic, feel free to close this topic.

12
Network / Sending information to a Mysql table
« on: January 29, 2013, 08:29:29 pm »
For example, say I in my game I have a player name and I want to be able to send their player name and score to a Mysql table to form a highscore results page. How would I go about doing this? Would the game interact with the table directly or would I connect to a php script which would interact with the Mysql table?

Pages: [1]