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

Pages: [1]
1
Graphics / Drawing sprites from class
« on: March 05, 2012, 03:15:40 am »
I really don't know how, but after reinstalling codeblock a couple of times and playing with settings for a couples of hours it finally works.

Thanks for helping.

2
Graphics / Drawing sprites from class
« on: March 03, 2012, 09:55:49 pm »
I did both things but none of them worked.

3
Graphics / Drawing sprites from class
« on: March 03, 2012, 08:22:28 pm »
I use codeblock and I tried many things to only show on the screen a sprite from a class. If I only use the main it works but I plan a bigger project so I need to be able to draw those sprites.

What I copy-paste here is the last try I did to make it work. The error is : undefined reference to Snake::Snake()' wich is my class

Theres nothing in the map.cpp for the moment so its not important.

main
Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include "snake.h"
#include "map.h"
#include <list>
#include <iostream>
#include <vector>



int main()
{


 int h = 45;
 int l = 45;

sf::RenderWindow App(sf::VideoMode(20*h, 20*l, 32), "Snake O Tron");
App.SetFramerateLimit(60);



Snake test;

std::vector<sf::Sprite> serpent;


std::vector<std::vector<int> > map(h, std::vector<int> (l,0));

 // Start game loop
    while (App.IsOpened())
    {
        // Process events
       sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }




App.Clear();


for(int i = 0; i<serpent.size(); i++)
{
    App.Draw(serpent[i]);
}





        App.Display();
    }

    return EXIT_SUCCESS;
}


snake.cpp
Code: [Select]
#include "snake.h"

using namespace std;
using namespace sf;

Snake::Snake()
{
    tete.Create(20, 20, Color(200,0,0));
    head.SetImage()(tete);
    head.setPosition(200.f, 200.f);
    affiche.push_back(head);
}



vector<Sprite> Snake::get_aff() const
{
    return affiche;
}



snake.h
Code: [Select]
#ifndef SNAKE_H_INCLUDED
#define SNAKE_H_INCLUDED

#include <SFML/Graphics.hpp>
#include <list>
#include <iostream>
#include <vector>


class Snake
{
    public:

    Snake();//constructeur
    std::vector<sf::Sprite>get_aff() const;
    std::vector<sf::Sprite> affiche;

    protected:



    private:

    sf::Image tete;
    sf::Sprite head;


};


#endif // SNAKE_H_INCLUDED

Pages: [1]
anything