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

Pages: [1]
1
This is some bad code i did

but it may help a beginner like me

It is a simple project which has 3 windows / forms

a splash screen, which swapps to menu, then fake game screen

enjoy

2
Graphics / Re: how to create and manage 20 sprites
« on: November 10, 2014, 10:21:34 pm »
ok thanks Ixrec

i come from vb6 and php so, some of these c++ things are a bit strange, getting a handle thou

i am reading books also, i am just having a play around with sfml


3
Graphics / Re: source to show using number / time with sfml text
« on: November 10, 2014, 10:05:41 pm »
point taken, i couldn't get it to work right away, just thought it may help folk, i guess wiki sfml

4
Graphics / Re: how to create and manage 20 sprites
« on: November 10, 2014, 10:03:02 pm »
i really had no idea a standard c++ std::vector could hold a sfml sprites object

thank you for your help

going off your code

sf::Sprite enemy;

how would i set the postion of sprite 4

say

enemy[3].setpostion(x,y);

??

thanks again




5
Graphics / how to create and manage 20 sprites
« on: November 10, 2014, 09:41:41 pm »
Hello simple newbie question here

If you were making the game pacman

There are say 20 badguys (ghosts)

Should i be creating 20 different sprites

    sf::Texture txBadPlayer;
    if (!txBadPlayer.loadFromFile("badplayer.png"))
    {
       return 0;
    }
    sf::Sprite spBadPlayer;
    spBadPlayer.setTexture(txBadPlayer);

 sf::Texture txBadPlayer2;
    if (!txBadPlayer2.loadFromFile("badplayer.png"))
    {
       return 0;
    }
    sf::Sprite spBadPlayer2;
    spBadPlayer2.setTexture(txBadPlayer2);
 

times 20

or should i use arrays or something ?

ps.. all bad guys have the same picture, but different movement

please could someone point me in the right direction
thanks

6
Graphics / source to show using number / time with sfml text
« on: November 10, 2014, 09:06:25 pm »
I thought i would post to help others, this works with sfml 2.1 codeblocks c++

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



int main()
{

    sf::Font font;
    font.loadFromFile("arial.ttf");

    sf::Text text;
    text.setFont(font);
    text.setPosition(100,100);
    text.setCharacterSize(34);
    text.setColor(sf::Color::Red);


    sf::Clock clock; // starts the clock
    sf::Time elapsed1; // set time object

    int intSecondsCounted;

    std::stringstream ss;



    sf::RenderWindow window(sf::VideoMode(800, 800), "Hag");
    // run the main loop

    while (window.isOpen())
    {
        // handle events

        sf::Event event;
        while (window.pollEvent(event))
        {
            if(event.type == sf::Event::Closed)
                window.close();
        }



        elapsed1 = clock.getElapsedTime();


        ss.str(std::string()); //clear the string
        ss << elapsed1.asSeconds();
        ss << std::endl << "Seconds Since I Started Counting";
        text.setString( ss.str().c_str() );

        window.draw(text);
        window.display();
        window.clear();

    }

    return 0;
}

 

7
Graphics / Re: mario 1 style advice
« on: November 08, 2014, 07:50:48 pm »
thank to your help i managed to make these bad bad game, but still learning, all good thanks



and



cheers

8
Graphics / Re: mario 1 style advice
« on: November 04, 2014, 03:47:58 pm »
just incase anyone wants to try this themselves

i have decided, tile mapping is right for my mini game and also tile map collision

if you take pacman as a sample

anyways

i have made some very basic code.. which will read a image, of 800 by 800 pixcels, cut it in to 32 by 32 squares and display all the squares in orders

which is below, from this i hope to make 1 screen per level games, whereby i used a txt file, which states which tiles can be passed over

the code is below

#include <SFML/Graphics.hpp>
#include <iostream>
#include <cmath>



int main()
{
    sf::Texture texture;
    if (!texture.loadFromFile("hag.png"))
    {
       return 0;
    }

    sf::Sprite box1;
    box1.setTexture(texture);

    sf::RenderWindow window(sf::VideoMode(800, 800), "Particles");

    // run the main loop
    while (window.isOpen())
    {
        // handle events
        sf::Event event;
        while (window.pollEvent(event))
        {
            if(event.type == sf::Event::Closed)
                window.close();
        }


        sf::Time elapsed = clock.restart();
      //  std::cout << (elapsed.asSeconds()*97680) << std::endl;


        window.clear();

        int lngRow = 0;
        int lngCol = 0;

        while(lngCol < 800)
        {
            lngRow = 0;
            while(lngRow < 800)
            {
                box1.setPosition(lngRow,lngCol);
                box1.setTextureRect(sf::IntRect(lngRow, lngCol, 32, 32));
                window.draw(box1);
                lngRow = lngRow + 32;
            }
            lngCol = lngCol + 32;

        }
        window.display();

    }

    return 0;
}






9
Graphics / Re: mario 1 style advice
« on: November 02, 2014, 07:28:40 pm »
thank you , onwards with the game

10
Graphics / Re: mario 1 style advice
« on: November 02, 2014, 07:00:52 pm »
this is sfml as far as i know

i am only using sfml, i only know sfml ~(slightly)

i admit, the same methods may be used in other frameworks, lib, engines etc

but why can i not just have a tiny bit of advice from an expert

it will save me a great deal of time, and i do not want to know how to do it

i'm not asking you to code it.. just point in me in the right direction

i'm sorry if its not in the wrong part of the forum, i'm sorry your clearly god

and a mere mortal as myself should not even speak to you

why don't you get a life, or better yet, be the big man and point out my bad grammar or spelling

thanks for your help anyways




11
Graphics / mario 1 style advice
« on: November 02, 2014, 04:03:12 am »
hello

i am trying to make a mario clone for fun

i have the sprite running, and a png as a large background image and the screen moving, if i run to which ever end of screen

ofcouse, he runs thur everything at the min

if i wanted mario to jump on to a box(like in the normal game)

should i be going down the route of

map tiles.. (to load the whole background image)
and then map tile collision

which i guess works on the system of

so................

you load the background image (mario level background), you load and display as tiles (chopping your image in to boxes on the fly)

and also you have a collision text file, with 0 and 1

and a loop, which checks if that tile, related to a 0 or 1

is that right.. or am i doing this the hardway ?

thank you

12
Window / Re: simple question - getting the height of the window
« on: September 30, 2014, 12:46:46 am »
thank you, your a life saver

works great

13
Window / Re: simple question - getting the height of the window
« on: September 30, 2014, 12:22:06 am »
Thank you for your answer, i will use your shape code thank you

i am having problems find the height of the window.. the bottom of the window

in order to say

when the shape.postion (x or y) gets to (bottom off window) - change direction

the 800 is a guess of the windows boarder

i dont know how to get the window boarder at the bottom, or width ?

any ideas


14
Window / simple question - getting the height of the window
« on: September 30, 2014, 12:03:29 am »
I am trying to make a shape bounce from the top of the window to the bottom and back, over and over

i can not get the height correct, so i guessed at 800

any ideas

thanks

------------------------------------------------------------------
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{

bool bShouldObjGoDown = true;


sf::RenderWindow window(sf::VideoMode(800, 800), "SFML Application");
// ,sf::Style::Fullscreen
window.setFramerateLimit(60);


sf::CircleShape shape;
shape.setRadius(40.f);
shape.setPosition(1, 1);
shape.setFillColor(sf::Color::Cyan);



while (window.isOpen())
{
    sf::Event event;
    while (window.pollEvent(event))
    {
        if (event.type == sf::Event::Closed)
        window.close();
    }
    window.clear();
    window.draw(shape);
    window.display();

    if(bShouldObjGoDown == true)
    {
        shape.move(0,5);
    }

    if(bShouldObjGoDown == false)
    {
        shape.move(0,-5);
    }

    std::cout << shape.getPosition().y << std::endl;

    if(shape.getPosition().y < 1)
    {
        bShouldObjGoDown = true;
    }
    if(shape.getPosition().y > 800)
    {
        bShouldObjGoDown = false;
    }

}

}
 


end

on the part

if(shape.getPosition().y > 800)

i want the 800 to be the botton of the window

i want the ball to bounce off the boarders

please help this is driving me crazy

thank you

Pages: [1]
anything