So I wanted to test out my skills with SFML
Finally got back into programming legit and SFML 2 so I decided to make a picking sticks game..
A picking sticks game is one where the player walks around like a topdown and when he collides with a stick you move the stick and he goes gets it again.
This type of game is important for beginners because it practices how to load resources, draw images and deal correctly with logic.
I added a twist though.. the player's speed (the crow) increases with the more sticks he picks up. No real reason behind it, just being a dick.
The graphics are poop (I know I could have done a WAY better job)
I'll provide the source code too so ya'll can learn from it and what not.
Workin' on a mac port (who the hell would want to play this game? lol)
Picking Sticks
Code!
Here is a screenshot
BONUS APP! (Windows Only.. Sowwie )
Ever wanted to insult your palls with style?
Download now this program I wrote that does it for you! Shakespeare style!
Shakespear Scoffer
This program is only possible on Micro$oft Windows because I used their SAPI libs for the voice synth.. if you guys want a mac port or linux I'll take up the challenge, it's a pretty fun app after all Also, source code if you guys want it too.
So this is going to be my demo dump thread. New games and cool apps I write will come here (including source code) so stay tuned! I'm working on a bomberman game now (so ambitious.. oh dear)
As for copying what ever I post in this thread, go nuts. I could really care less, just don't claim you made any of it. If you edit it and use it as your own, no need to give creds just happy to help. Basically the "Do what ever the fuck you want" license on everything I post in here.
Finally got back into programming legit and SFML 2 so I decided to make a picking sticks game..
A picking sticks game is one where the player walks around like a topdown and when he collides with a stick you move the stick and he goes gets it again.
This type of game is important for beginners because it practices how to load resources, draw images and deal correctly with logic.
I added a twist though.. the player's speed (the crow) increases with the more sticks he picks up. No real reason behind it, just being a dick.
The graphics are poop (I know I could have done a WAY better job)
I'll provide the source code too so ya'll can learn from it and what not.
Workin' on a mac port (who the hell would want to play this game? lol)
Picking Sticks
Code!
Code:
#include <iostream>
#include <SFML\Window.hpp>
#include <SFML\Graphics.hpp>
#include <SFML\Audio.hpp>
int main(void)
{
srand(clock());
sf::RenderWindow sf_window(sf::VideoMode(420, 380), "Picking Sticks", sf::Style::Close);
sf_window.setFramerateLimit(60);
sf::Event sf_event;
sf::Keyboard sf_keyboard;
sf::Texture sf_texture;
if(!sf_texture.loadFromFile("resources/background.png"))
return EXIT_FAILURE;
sf::Sprite sf_background;
sf_background.setTexture(sf_texture, false);
sf::Texture sf_sprite_a;
if(!sf_sprite_a.loadFromFile("resources/crow.png"))
return EXIT_FAILURE;
sf::Sprite sf_spr_crow;
sf_spr_crow.setTexture(sf_sprite_a, false);
sf::Texture sf_sprite_b;
if(!sf_sprite_b.loadFromFile("resources/stick.png"))
return EXIT_FAILURE;
sf::Sprite sf_spr_stick;
sf_spr_stick.setTexture(sf_sprite_b, false);
sf::SoundBuffer sf_sndbuffer;
sf_sndbuffer.loadFromFile("resources/sound.wav");
sf::Sound sf_snd_crow;
sf_snd_crow.setBuffer(sf_sndbuffer);
int pos_x = sf_window.getSize().x / 2;
int pos_y = sf_window.getSize().y / 2;
int counter = 0;
int speed = 1;
while(sf_window.isOpen())
{
while(sf_window.pollEvent(sf_event))
{
if(sf_event.type == sf::Event::Closed)
sf_window.close();
}
if(sf_keyboard.isKeyPressed(sf::Keyboard::Escape))
sf_window.close();
if(sf_keyboard.isKeyPressed(sf::Keyboard::Left))
pos_x -= speed;
if(sf_keyboard.isKeyPressed(sf::Keyboard::Right))
pos_x += speed;
if(sf_keyboard.isKeyPressed(sf::Keyboard::Up))
pos_y -= speed;
if(sf_keyboard.isKeyPressed(sf::Keyboard::Down))
pos_y += speed;
if(pos_x < 0)
pos_x = 0;
if(pos_x > sf_window.getSize().x - sf_spr_crow.getLocalBounds().height)
pos_x = sf_window.getSize().x - sf_spr_crow.getLocalBounds().height;
if(pos_y < 0)
pos_y = 0;
if(pos_y > sf_window.getSize().y - sf_spr_crow.getLocalBounds().width)
pos_y = sf_window.getSize().y - sf_spr_crow.getLocalBounds().width;
sf_spr_crow.setPosition(pos_x, pos_y);
if(sf_spr_crow.getGlobalBounds().intersects(sf_spr_stick.getGlobalBounds()))
{
if(sf_snd_crow.getStatus() != sf::Sound::Playing)
sf_snd_crow.play();
sf_spr_stick.setPosition(rand() % 344, rand() % 316);
counter++;
speed++;
}
sf_window.clear();
sf_window.draw(sf_background);
sf_window.draw(sf_spr_crow);
sf_window.draw(sf_spr_stick);
std::cout << counter << '\r';
sf_window.display();
}
return 0;
}
Here is a screenshot
BONUS APP! (Windows Only.. Sowwie )
Ever wanted to insult your palls with style?
Download now this program I wrote that does it for you! Shakespeare style!
Shakespear Scoffer
This program is only possible on Micro$oft Windows because I used their SAPI libs for the voice synth.. if you guys want a mac port or linux I'll take up the challenge, it's a pretty fun app after all Also, source code if you guys want it too.
So this is going to be my demo dump thread. New games and cool apps I write will come here (including source code) so stay tuned! I'm working on a bomberman game now (so ambitious.. oh dear)
As for copying what ever I post in this thread, go nuts. I could really care less, just don't claim you made any of it. If you edit it and use it as your own, no need to give creds just happy to help. Basically the "Do what ever the fuck you want" license on everything I post in here.