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

Pages: [1]
1
General / Re: Can't get MapRenderer class to work
« on: November 10, 2015, 06:11:00 am »
That did the trick. Thank you!  :)

2
General / Re: Can't get MapRenderer class to work
« on: November 06, 2015, 06:56:37 am »
Tried several combinations of alpha and rgb. Doesn't seem that's it...

Anyone got example code of this class being used with an actual SpriteSheet?

3
General / Re: Can't get MapRenderer class to work
« on: November 06, 2015, 04:57:50 am »
Tried that, started getting an opaque white instead. So I tried this:

void provider(int x, int y, int layer, Color& color, IntRect &src)
{
   color.a = 0;
   color.b = 100;
   src = IntRect(10, 42, 32, 32);
}

And that gave me the same empty blackness as before...  :(

4
General / Can't get MapRenderer class to work
« on: November 06, 2015, 12:02:01 am »
Ok, I'm trying to use the MapRenderer class provided here (http://pastebin.com/SrBE69EC), and it works fine with the built in example, that draws only colored tiles with no texture, wrapping around. The moment I try to get a spritesheet into the mix, it stops working, and I get a black screen with nothing. Here's the relevant code:

#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>

#include "World.h"
#include "MapRenderer.h"
using namespace sf;

#define screenWidth  1024
#define screenHeight 768
#define PI 3.14
#define fps 30
#define tileSize 32

void provider(int x, int y, int layer, Color& color, IntRect &src)
{
        //color = Color::Yellow;
        src = IntRect(10, 42, 32, 32);
}

void main()
{
        sf::Clock clock; // starts the clock
        sf::Time elapsed = elapsed.Zero;
        sf::RenderWindow window(sf::VideoMode(screenWidth, screenHeight), "SFML works!");

        View view = window.getDefaultView();
        Texture texture;
        texture.loadFromFile("World_A2.png");
        MapRenderer map(&texture, provider, 32, 1);
        Vector2f prev;

        tgui::Gui gui(window);
        gui.setGlobalFont("TGUI/fonts/DejaVuSans.ttf");
        World *world=new World;
        world->generate(1000,1000);
        int screenX=500, screenY=500;

        //Main Loop
       
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        Vector2f ms, delta;
                        switch (event.type)
                        {
                        case Event::Closed:
                                window.close();
                                break;
                        case Event::Resized:
                                view.setSize(event.size.width, event.size.height);
                                view.setCenter(view.getSize() * 0.5f);
                                break;
                        case Event::MouseMoved:
                                ms = Vector2f(event.mouseMove.x, event.mouseMove.y);
                                delta = ms - prev;
                                if (Mouse::isButtonPressed(Mouse::Button::Left))
                                        view.setCenter(view.getCenter() - delta);
                                prev = ms;
                                break;
                        case Event::KeyPressed:
                                map.refresh();
                                break;
                        }

                        gui.handleEvent(event);
                }
                elapsed += clock.restart();
                if (elapsed.asMilliseconds() > 1000 / fps) // is it time to loop again?
                {
                        elapsed -= sf::milliseconds(1000 / fps);
                        window.clear();
                        window.setView(view);

                        map.update(window);
                        window.draw(map);
//                      Sprite test;
//                      test.setTexture(texture);
//                      window.draw(test);   <-This was to test if the texture was actually loading correctly, it does
// draw the spritesheet on screen when uncommented
//GUI

                        gui.draw();
                        window.display();
                }
                else sf::sleep(sf::milliseconds(10));
        }

}


Any help?  :-[

5
General / Re: Unhandled Exception Stack Overflow in crtexe.c
« on: October 22, 2015, 06:56:22 pm »
Bingo! World holds information on the entire 1000x1000 tile map after all. As soon as I commented that part out, it started accepting both implementations. Funny thing is, the stack overflow happens before the first line of code inside main is executed at all, before it even gets to "World W;".

Yeah, I'm quite the noob at this stuff. So... is there any way to keep this class large as it's supposed to be, but at the same time tell the compiler "don't query this object's address every time you access it, the address is always the same!"?

6
General / Unhandled Exception Stack Overflow in crtexe.c
« on: October 22, 2015, 12:50:09 am »
I'm using Visual Studio Express 2013 with SFML 2.3.2.
I have this class called World and I create a pointer to it in main. I then create a new World with the pointer:

World *W = new World;

No problems up to this point. Then I thought to myself, "Why am I creating a pointer to a class I'll have only one unchanging instance of throughout the entire execution? Having to look an object's address up as if it can change when it never does is wasteful, right? So I changed it to static allocation instead:

World W;

All hell broke loose. The moment execution enters void main at all, before getting to the first line of code inside, I get an unhandled exception, stack overflow in crtexe.c. Any ideas?

Pages: [1]