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.


Topics - Paki Programmer

Pages: [1]
1
Graphics / Making a "Paint" Application
« on: September 28, 2012, 04:00:22 am »
Ok, so I decided to try and make a MS Paint like application in which you can draw using different brushes, colors, shapes, etc. I just wanted someone to look at my code and tell me if I'm headed in the right direction with this or if I need to approach the "drawing" aspect differently or something. The code is a little bit messy and unorganized because I typed it up quickly just to get a rough idea of where to start. Ill eventually put everything in classes and encapsulate it so worry not ;) Any feed back is appreciated

Here's the code:


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

float x, y;

int r, g, b;

sf::RenderWindow window(sf::VideoMode(800, 600), "Paint Application");

std::list<sf::CircleShape> circles;
std::list<sf::CircleShape>::iterator iter;

void add(sf::CircleShape shape)
{
        circles.push_back(shape);
}

void update()
{
        iter = circles.begin();

        while (iter != circles.end())
        {
                window.draw(*iter);
                iter++;
        }

        //std::cout << circles.size() << std::endl;
}

int main()
{
        sf::Event ev;

        //srand((unsigned int) time(0));

        while (window.isOpen())
        {
                while (window.pollEvent(ev))
                {
                        switch (ev.type)
                        {
                        case sf::Event::Closed:
                                {
                                        window.close();
                                }
                                break;

                        case sf::Event::KeyPressed:
                                {
                                        switch (ev.key.code)
                                        {
                                        case sf::Keyboard::Escape:
                                                {
                                                        window.close();
                                                }
                                                break;
                                        }
                                }
                                break;
                        }
                }

                if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
                {
                        x = (float) sf::Mouse::getPosition((window)).x;
                        y = (float) sf::Mouse::getPosition(window).y;

                        r = 255;
                        g = 0;
                        b = 255;

                        sf::CircleShape point(2);
                        point.setPosition(x, y);
                        point.setFillColor(sf::Color(r, g, b));
                        add(point);
                }

                if (sf::Mouse::isButtonPressed(sf::Mouse::Right))
                {
                        x = (float) sf::Mouse::getPosition((window)).x;
                        y = (float) sf::Mouse::getPosition(window).y;

                        r = 0;
                        g = 215;
                        b = 255;

                        sf::CircleShape point(2);
                        point.setPosition(x, y);
                        point.setFillColor(sf::Color(r, g, b));
                        add(point);
                }

                if (sf::Mouse::isButtonPressed(sf::Mouse::Middle))
                {
                        x = (float) sf::Mouse::getPosition((window)).x;
                        y = (float) sf::Mouse::getPosition(window).y;

                        r = 0;
                        g = 0;
                        b = 0;

                        sf::CircleShape point(2);
                        point.setPosition(x, y);
                        point.setFillColor(sf::Color(r, g, b));
                        add(point);
                }

                window.clear();
                update();
                window.display();
        }
       
        return 0;
}

 

2
SFML projects / Make a Dev Team?
« on: July 20, 2012, 02:36:17 pm »
I've been feeling rather lonely lately so I though what better way to fix that than to make games with a dev team ;) I want to make a team that can work with me to create some 2D games...starting off a bit simple and then working our way up to something more elaborate. The main goal I suppose would be to just have fun and not take the projects too seriously because people start losing interest and motivation when that happens based on past experiences. Communication and Version Control can be decided on together once a small team has been made.

Pretty much need another programmer to work along side me and maybe 2 artists. If you want more info or are interested in joining just PM me, comment on this post, or email me at sarim.janjua2013@gmail.com

3
Window / Calculating Framerate
« on: June 12, 2012, 03:27:05 am »
Could someone please help me understand how to create a timer in SFML 2.0 RC that keeps track of framerate? I would like my game to run at the same speed on all systems. For instance how would i go about getting about 60 fps? I tried the tutorials and looking around on the web but I'm still kinda stuck. Thanks

4
Graphics / Color Masking in SFML 2.0 RC
« on: May 28, 2012, 05:02:39 pm »
How would you go about using color masks in SFML 2.0? I remember in SFML 1.6 if was something like image.CreateColorMask() or something like that. But now in 2.0 I can't seem to figure out how to do that, especially since sprites are now "textures" and not "images". Any help? Thanks

5
General discussions / C++/Game Programming Tutoring Classes
« on: May 03, 2012, 05:41:49 pm »
I am willing to teach anyone who is interested C++ and the SFML 2.0 API used to make games. Classes will be held over Skype or GoogleTalk and TeamViewer will be used for real time collaboration and help. Payments will be based on an hourly rate and PayPal will be used for secure transactions. You set how many hours you want me to teach, then pay half the amount to me. Once the lesson is done and the appropriate amount of hours are up, you pay the rest to me. If you are interested please email me at sarim.janjua2013@gmail.com

Payment rate: $10/hour

Students will begin the classes by learning the basics of C++ if they don't already. This includes:

- Understanding of basic theory

- Variables

- Loops

- Conditional Statements

- Functions

- Classes, structures, enumerations, etc.

- Pointers

- Containers/Lists

- Arrays

- More will be added as the classes go in case i feel as though you need to know something else

After a solid foundation has been built with an understanding of C++, students will move onto the next phase and begin to learn game development through the use of the SFML 2.0 API. The ultimate goal of all the lessons combined is to allow the student to make games by themselves with little help if any. Topics for this part of the class that will be taught are:

- Basic game structure

- Rendering sprites

- Player input

- Basic physics - Game audio/music - More will be added and taught as needed

The lesson style that I use to teach involves making students write many small programs that involve concepts that they are currently learning. They will write, test, then rewrite similar programs many times until they know the concepts by heart and are capable of moving on to the next lesson. Each lesson is in essence a small puzzle piece. Once students learn enough concepts, a sort of "test" will be issued which requires students to create a simple game incorporating all of the concepts they have learned thus far.

Many people might say that they can just learn from the internet and go on youtube or search forums. That is true, however you won't get the same experience of working with another person in real time who will talk to you and guide you through the whole process. If you get stuck then I'm there to tell you what you did wrong and what you can do to fix it. You can't get the same experience and learn at the same rate as you would learning from me if you just rely on the internet.

A little bit about me for those who are curious. I am a student and I plan on getting my degree in Computer Science and continue on to become a Software Engineer. These classes that I am offering are not expensive at all, especially considering how much professional classes are. I have experience making games with small indie teams but none were ever finished due to various reasons. I have enough understanding and knowledge about C++ and Game Development to teach those who desire help from me.

An additional note, I live in the United States, EST Time. Please take that into account in case you live somewhere else in the world as timing will be difficult if not thought of before hand.

6
Graphics / 2.0 RC sf::Text bug
« on: May 03, 2012, 12:06:43 am »
When using sf::Text, there seems to be a bug where the letters of the string seem to be surrounded by a light blue outline. I took a screen print to show you what i mean. Any clues why this is happening or how to fix it? Or is it really just a bug in the API?



[attachment deleted by admin]

7
General / Entity System Not Working Right
« on: February 06, 2012, 11:18:43 pm »
So in the game that I'm working on at the moment, I've encountered a small bug that i can't seem to fix. I set up the beginning of my entity system to keep track of all the objects in the game and update them accordingly. It works fine for now except for the fact that it doesn't render them to the screen as it is suppose to. It renders the white shape of the sprite instead of the actual image with it.

Here's some of the code for it. If you need more let me know and ill post it.

//Entity Manager

Code: [Select]


#include "Manager.h"
#include "engine.h"

Manager cManager;

void Manager::Update()
{
this -> iter = this -> entities.begin();

Object object;

while (this -> iter != this -> entities.end())
{
object = *iter;

cEngine.cWindow.Draw(object.Sprite);

iter++;
}
}

void Manager::Add(Object object)
{
this -> entities.push_back(object);
}




//Game.cpp

Code: [Select]


#include "Game.h"
#include "Manager.h"
#include "engine.h"

Game cGame;

void Game::Game_Init()
{
Character player;
player.Create("ball.bmp", 200, 200, 45, 45);

cManager.Add(player);
}

void Game::Game_Run()
{
cEngine.cWindow.Clear();
cManager.Update();
cEngine.cWindow.Display();
}



//Character.pp

Code: [Select]


#include "Object.h"
#include "engine.h"

int Character::Create(std::string filename, float x, float y, int width, int height)
{
if (!this -> Image.LoadFromFile(filename.c_str()))
{
return 0;
}

this -> Image.CreateMaskFromColor(sf::Color(255, 0, 255));

this -> Sprite.SetImage(this -> Image);
this -> Sprite.Resize(width, height);
this -> Sprite.SetPosition(x, y);

this -> PosX = this -> Sprite.GetPosition().x;
this -> PosY = this -> Sprite.GetPosition().y;

this -> Rect.Left = this -> PosX;
this -> Rect.Top = this -> PosY;
this -> Rect.Width = width;
this -> Rect.Height = height;

return 1;
}


8
General / Unhandled Exception
« on: January 27, 2012, 02:46:38 am »
I dont know what im doing wrong but for some reason I keep getting an unhandled exception my my entity manager. I try to draw the sprite to the screen and right before the entity manager updates and trys to draw it everything is fine. But as soon as it attempts to draw the sprite i get an exception. Here's the code. Can someone please help me ? This is driving me nuts :( if you need the whole project just let me know and ill email it to you

//Game.cpp

Code: [Select]

#include "EntityManager.h"

void System::Init()
{
engine = new System();

engine -> SetWindow(800, 600, "Test");

Entity player;
player.Load("test.png", 100, 100);

manager.Add(player);
}

void System::Run()
{
sf::Event ev;

while (engine -> window -> IsOpened())
{
engine -> window -> PollEvent(ev);


engine -> window -> Clear();
manager.Update();
engine -> window -> Display();
}
}


//System.cpp

Code: [Select]

#include "System.h"

void System::SetScreenDim(int width, int height)
{
this -> SCREENW = width;
this -> SCREENH = height;
}

void System::SetTitle(std::string title)
{
this -> Title = title;
}

void System::SetWindow(int width, int height, std::string title)
{
this -> SCREENW = width;
this -> SCREENH = height;
this -> window = new sf::RenderWindow(sf::VideoMode(width, height), title.c_str());
}


//EntityManager.cpp

Code: [Select]

#include "EntityManager.h"
#include "System.h"

void Manager::Update()
{
Entity entity;

std::list<Entity>::iterator iter = eList.begin();

while (iter != eList.end())
{
entity = *iter;

entity.GetSprite().SetPosition(entity.GetX(), entity.GetY());

engine -> window -> Draw(entity.GetSprite());

iter++;
}
}

void Manager::Add(Entity entity)
{
eList.push_back(entity);
}


//Entity.cpp

Code: [Select]

#include "Entity.h"

void Entity::Load(std::string filename, float x, float y)
{
this -> Filename = filename;

this -> Image.LoadFromFile(this -> Filename.c_str());
this -> Sprite.SetImage(this -> Image);

this -> posx = x;
this -> posy = y;
}

void Entity::Update()
{
this -> Sprite.SetPosition(this -> posx, this -> posy);
}
[/code]

9
General / Noncopyable Error
« on: January 26, 2012, 11:22:45 pm »
Ive looked around on other forums and this one and i think im certain that im trying to copy the sf::RenderWindow window that i made for my game engine...and according to what i've found that's not possible. I suppose i have to make a pointer to the window or a reference but since im still fairly rusty with programming (haven't used C++ for a while) i dont know how to go about doing this. Here are the two parts of my code i think are causing the trouble. Any idea how i can go about creating a reference or pointer to the render window ?


Code: [Select]

sf::RenderWindow System::SetWindow(int width, int height, std::string title)
{
sf::RenderWindow *ref = new sf::RenderWindow();
sf::RenderWindow w(sf::VideoMode(width, height), title.c_str());

ref = &w;

return *ref;
}


Code: [Select]

void System::Init()
{
engine = new System();
window = new sf::RenderWindow();

engine -> window = &engine -> SetWindow(800, 600, "Test");
}


And also here is the error i keep getting:

    Error   1   error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'   c:\program files\sfml 2.0\include\sfml\window\window.hpp   479


    Error   2   error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'   c:\program files\sfml 2.0\include\sfml\graphics\rendertarget.hpp   304


10
General discussions / SFML 2.0
« on: January 23, 2012, 12:59:32 am »
Just a question...when is the official version of SFML 2.0 going to come out?

11
General / Buffer overload in release build
« on: February 24, 2011, 04:40:13 am »
For some reason on my version of VC++ 2010 i cant create a release build. I keep gettin a buffer overrun error. What could be the problem? I linked my libs fine because i can run it in debug.

12
General / I dont have the Clear() function :(
« on: February 17, 2011, 02:54:37 am »
for some reason i dont have the Clear() function in SFML for VC++ 2010. Does anyone know how to fix this problem??? I cant change the background color without it

Pages: [1]