Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Question about level map  (Read 1554 times)

0 Members and 2 Guests are viewing this topic.

smiaro

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Question about level map
« on: December 15, 2013, 12:35:16 pm »
Hello, sorry if topic is not in a correct place :)
I have to create game project in C++ for my university, I created Game States, Menu etc but now I want to create level and I need so much your help. (I use SFML 2.0)
I am not good in C++ and this library but I have to pass my subject and create nice looking game :)

In my game class I have something like this:
case Game::Play:
{
        sf::Event event;
        while (oknoAplikacji.pollEvent(event))
        {
                gameWindow.clear(sf::Color(0, 0, 0));

                //I think something with level class here :)

                gameWindow.display();

                if (event.type == sf::Event::Closed) gameState= Game::Exit;

                if (event.type == sf::Event::KeyPressed)
                {
                        if (event.key.code == sf::Keyboard::Escape) ShowMenu();
                }
        }
break;
}
 

I want to create level like in my attachment, in foreground I want to draw my own image and characters should move and jump on that image. I want to control my character and enemy moves automatic. Background should be static image. Game should be like tanks. My turn (10 seconds), enemy turn(10 seconds) and again and again...
How to create this level?:) Please help, this is very important for me:) I need simple solutions :) And I know my english is very bad, sorry :(
« Last Edit: December 15, 2013, 02:00:43 pm by smiaro »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Question about level map
« Reply #1 on: December 15, 2013, 01:09:08 pm »
You should have a look at the SFML tutorials, everything is explained there. To display images, you need the classes sf::Texture (to hold the image data) and sf::Sprite (to display it on the screen). The order in which you draw the sprites determines what is in front of what.

By the way, please use the correct code tags:
[code=cpp] your code [/code]
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

smiaro

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Re: Question about level map
« Reply #2 on: December 15, 2013, 02:02:25 pm »
I know how to draw image and how to use sprites but I don't know how to put character to go on that image in foreground and how to ceter my character and control camera. And how to do turns :( So i wrote here :)

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Question about level map
« Reply #3 on: December 15, 2013, 02:49:54 pm »
Don't take this post the wrong way, but we aren't here to write the logic for your game. This is something you need to do yourself. If you want a game with turns then write code that contains that logic. As far as I can tell you haven't even attempted to write any of this logic. Maybe you should switch over to the console (and avoid SFML for now) and try to get your logic for your game working. After all, part of coding is being able to break a seemingly complex problem into smaller simpler steps (this is called logical thinking). This is a crucial skill that you can not rely on other people to do for you.

Quote
I don't know how to put character to go on that image in foreground

If you are talking about Z-Order then it depends on the order of the draw calls, so draw your character last.

Quote
how to ceter my character and control camera

Take a look at the views tutorial  ;)

Also, I recommend you take another look at the tutorials about handling events and drawing since your current code is wrong (hint: drawing in event loop).
« Last Edit: December 15, 2013, 03:03:45 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor