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

Pages: [1]
1
General / Question about lighting in 2D game.
« on: May 18, 2014, 07:45:54 pm »
Hello there.
I've been talking with my friend about making a 2D game in SFML 2.1 and we wanted to make (kinda) realistic lighting. Let me use as example this trailer for Crawl https://www.youtube.com/watch?v=2_3xrqjTyes. We really liked the view perspective this game shows, but the thing that really bugged us were lights that... didn't light up the room and didn't reflect on the walls. So here's our question - is it possible to make a decent lighting in SFML for 2D game without resorting to "3D" graphics and/or some sketchy code? (The whole idea is pretty much in infancy, so we're sorry for not being more specific -  we were just wondering if there is an easy way to do it)

2
SFML projects / Re: 2d game engine done by a newbie - progress diary
« on: October 21, 2013, 10:20:56 pm »
Thanks a ton SneakySnake. I'm going to read Git stuff tomorrow and for making my code Linux-friendly have a classy pug on a horse: http://oi42.tinypic.com/2ajndp3.jpg :)

3
Graphics / Re: Creating player class.
« on: October 21, 2013, 05:06:09 pm »
God, now I feel stupid.. Yeah, you're totally right - I need to redraw everything with each loop so why not do character movement this way. I really should rethink stuff before posting - thanks for help!

4
Graphics / Creating player class.
« on: October 21, 2013, 04:37:59 pm »
Hello there. I'm currently trying to implement player class to my game (here's the link to my topic with code if you're curious: http://en.sfml-dev.org/forums/index.php?topic=13253.0). However, I'm kind of stuck at how should I do it. Should I just redraw character sprite with each loop, with position depending on input? Is there some kind of method my brain cannot fathom? I'd appriciate any form of help on the matter.

(also, if there's a topic on this subject, then I'm sorry I made another one - search function gave me nothing)

5
SFML projects / Re: 2d game engine done by a newbie - progress diary
« on: October 20, 2013, 10:07:23 pm »
Ok. I did mapping based on Vertex arrays. I don't know how to use sites like google.code so until I get around to learn how it works I'll continue to upload entire code.

Next time I'm going to add some kind of camera movement - I'll have to do some research tho.

As always, feedback is appriciated!

LINK: http://s000.tinyupload.com/index.php?file_id=00971552907888389184

6
SFML projects / Re: 2d game engine done by a newbie - progress diary
« on: October 17, 2013, 11:19:18 pm »
Thanks again for the input Ixrec! That's really handy and kind of easy to use - I'm going to code it tomorrow.

@Edit: Nevermind, I'll do it on Saturday.

7
SFML projects / Re: 2d game engine done by a newbie - progress diary
« on: October 17, 2013, 10:16:52 pm »
Ok, I'm stuck. Could someone give me an idea for making a map? My current idea is kinda dumb. Here's my code - it's not compiling but it'll explain it better than I would.

http://s000.tinyupload.com/index.php?file_id=52683591925031820198

The idea is really primitive behind mapping is primitive, but I wanted to ask about one other thing while I'm at it. In Mapping.h I have a vector in which I hold my Tiles. If I want to use Tile class functions from them, how would I do that? Is the way I'm doing it right?

I'm going to set up google.code or something along those lines in the near future, so you don't have to download the source all the time.

8
SFML projects / Re: 2d game engine done by a newbie - progress diary
« on: October 16, 2013, 09:36:37 pm »
Thanks for feedback ChronicRat. Gonna try to add asserts from now on. I didn't have much time latety, but I'll try to make some mapping class tonight. Gonna share it ofc! :)

9
SFML projects / Re: 2d game engine done by a newbie - progress diary
« on: October 15, 2013, 12:30:23 am »
Hmmm... I think I might do just that. I mean my goal was to make a game based on this engine anyway, so might as well start throwing stuff in for this specific reason from the start. Also, I'll remake the project with "blank project" option. Thanks for the tips!

10
SFML projects / 2d game engine done by a newbie - progress diary
« on: October 15, 2013, 12:17:37 am »
Hey there. I'm slowly but surely making my first 2d game engine in SFML 2.1. I figured that sice I'm making it, I might as well share my code, and get some feedback to make it better :)

15.10.2013
http://speedy.sh/V88ww/IncuEngine-15.10.rar
20.10.2013
http://s000.tinyupload.com/index.php?file_id=00971552907888389184
What's in so far:
- Main loop and all the basics
- image manager class
- tile class
- basic mapping
To be done next:
- basic camera movement

11
Graphics / Re: Placing image on the screen - problem.
« on: October 09, 2013, 07:57:36 am »
SOLVED! Turns out it really was just a dumb mistake. My picture was bigger than the size I put in my code

12
Graphics / Re: Placing image on the screen - problem.
« on: October 09, 2013, 01:10:30 am »
Ok, I'll post the assertion error tomorrow then. Thanks for testing the code tho, now I won't spend all the time thinking what I did wrong :)

13
Graphics / Re: Placing image on the screen - problem.
« on: October 09, 2013, 01:05:58 am »
Ok, I'm still up so I'll add what exactly is my problem. As I said I'm getting really sleepy so I didn't think the post through... :s Ok so, I wanted to put my test image (the one from Engine::LoadImages() - it is in the right folder) on the screen. What I get is some strange assertion error (thus my assumption that I made a mistake in the code) and after I skip the error, I get a black screen (probably meaning, that it's doing the "window clear" stage) That's all I can tell with my tired mind - I hope it helps!

@Up
Edited 1st post with details

14
Graphics / Placing image on the screen - problem.
« on: October 09, 2013, 12:48:40 am »
Hello, I have a problem with getting my image on the screen. Since I only started learning SFML today, I probably just did some dumb mistake due to my lack of knowledge and understanding, but I can't figure out what it is and I'm getting sleepy... If you have some time, please take a look and point it out if you can find it. Thanks in advance!

#Edit: Since I didn't put the more detailed explanation of my problem, I'm doing it now: Ok so, I wanted to put my test image (the one from Engine::LoadImages() - it is in the right folder) on the screen. What I get is some strange assertion error (thus my assumption that I made a mistake in the code) and after I skip the error, I get a black screen (probably meaning, that it's doing the "window clear" stage) That's all I can tell with my tired mind - I hope it helps!

(If this subforum isn't for such requests, then I'm sorry and simply ignore this thread)

MAIN.cpp
#include <Windows.h>

#include "Engine.h"

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
        Engine* engine = new Engine();

        try
        {
                engine->Go();
        }
        catch(char* e)
        {
                MessageBoxA(NULL, e, "Exception Occured", MB_OK | MB_ICONERROR);
        }
}
 

Engine.h
#ifndef _ENGINE_H
#define _ENGINE_H

#include <SFML\Graphics.hpp>
#include "ImageManager.h"
#include "Tile.h"


class Engine
{
private:
        //Image'n'tile stuff
        ImageManager imageManager;

    void LoadImages();

    Tile* testTile;

        //Render that window
        sf::RenderWindow *window;

        //Starto!
        bool Init();

        //Main Game loop
        void MainLoop();
        //Render one frame
        void RenderFrame();
        //Processes user input
        void ProcessInput();
        //Update engine intervals
        void Update();

public:
        Engine();
        ~Engine();

        //start that engine
        void Go();


};

#endif

Engine.cpp
#include "Engine.h"
#include <SFML\Graphics.hpp>



Engine::Engine()
{

}


Engine::~Engine()
{

}

//image stuff
void Engine::LoadImages()
{
        sf::Image image;
        image.loadFromFile("test.png");

        imageManager.AddImage(image);

        testTile = new Tile(imageManager.GetImage(0));
}

void Engine::RenderFrame()
{
        window->clear();
        testTile->Draw(0,0, window);
        window->display();
}




//startup stuff \/
bool Engine::Init()
{
        window = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "IncuEngine");

        if(!window)
                return false;
        LoadImages();

        return true;
}

//basic user input process
void Engine::ProcessInput()
{
        sf::Event event;
    while (window->pollEvent(event))
    {
        // Request for closing the window
        if (event.type == sf::Event::Closed)
            window->close();
    }
}

void Engine::Update()
{

}

void Engine::MainLoop()
{
        while(window->isOpen())
        {
                ProcessInput();
                Update();
                RenderFrame();
        }
}

void Engine::Go()
{
        if(!Init())
                throw "Engine initialization failed.";

        MainLoop();
}

 

Tile.h
#ifndef _TILE_H
#define _TILE_H

#include <SFML\Graphics.hpp>


class Tile
{
private:
        sf::Texture baseTexture;
        sf::Sprite baseSprite;

public:
        Tile(sf::Image& image);
        ~Tile(void);

        void Draw(int x, int y, sf::RenderWindow* rw);
};

#endif

Tile.cpp
#include "Tile.h"


Tile::Tile(sf::Image& image)
{
        baseTexture.create(200,200);
        baseTexture.update(image);
}


Tile::~Tile(void)
{
}

void Tile::Draw(int x, int y, sf::RenderWindow* rw)
{
        baseSprite.setTexture(baseTexture);
        baseSprite.setPosition(x, y);
        rw->draw(baseSprite);
}


 

ImageManager.h
#ifndef _IMAGEMANAGER_H
#define _IMAGEMANAGER_H

#include <vector>
#include <SFML\Graphics.hpp>

class ImageManager
{
private:
        std::vector <sf::Image> imageList;
public:
        ImageManager(void);
        ~ImageManager(void);

        void AddImage(sf::Image& image);
        sf::Image& GetImage(int index);
};

#endif
 

Image.cpp
#include "ImageManager.h"


ImageManager::ImageManager(void)
{
}


ImageManager::~ImageManager(void)
{
}

void ImageManager::AddImage(sf::Image& image)
{
        imageList.push_back(image);
}

sf::Image& ImageManager::GetImage(int index)
{
        return imageList[index];
}
 

Pages: [1]