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

Pages: [1] 2 3 4
1
System / Re: Not understanding threads in SFML?
« on: March 25, 2017, 09:36:02 pm »
So in other words, if i'm not explicitly creating a new thread, then its all running in the main thread?

Okay if thats the case, then its all too easy. Thanks  :D

2
System / Not understanding threads in SFML?
« on: March 23, 2017, 06:07:06 am »
I was reading that in a Mac OS X, i'm only able to run window and handle events within the main thread. I'm not sure i understand that! According to the wiki, the main thread is main function. What classifies another form of thread? I havent touch that topic of threads in my C++ book, nor do i think they talk about it.

Here is my code and how i have it orientated.
//
//  Engine.hpp
//  RetroPongGame
//
//  Created by Jonathan Vazquez on 3/22/17.
//  Copyright © 2017 Jonathan Vazquez. All rights reserved.
//

#ifndef Engine_hpp
#define Engine_hpp

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

class Engine{

    public:
        Engine();
        ~Engine();
   
        void gameLoop();
        void eventHandler();
        void render();
       
   
    private:
        std::string winTitle;
        unsigned int winHeight, winWidth;
        sf::RenderWindow window;
   
};

#endif /* Engine_hpp */
 

//
//  Engine.cpp
//  RetroPongGame
//
//  Created by Jonathan Vazquez on 3/22/17.
//  Copyright © 2017 Jonathan Vazquez. All rights reserved.
//

#include "Engine.hpp"

Engine::Engine(): winTitle("Retro Pong Game v2.0"),winHeight(800),winWidth(1200){
    window.create(sf::VideoMode(winWidth, winHeight), winTitle, sf::Style::Titlebar | sf::Style::Close);
    window.setVerticalSyncEnabled(true);
}
Engine::~Engine(){
}

void Engine::gameLoop(){
    while(window.isOpen()){
        eventHandler();
    }
   
    // Clear screen
    window.clear();
   
    //rendering
    render();
   
    // Update the window
    window.display();
}

void Engine::eventHandler(){
    // Process events
    sf::Event event;
    while (window.pollEvent(event))
    {
        // Close window: exit
        if (event.type == sf::Event::Closed)
            window.close();
       
        // Escape pressed: exit
        if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)
            window.close();
    }
}

void Engine::render(){
    // Draw the sprite
    //window.draw(sprite);
   
    // Draw the string
    // window.draw(text);
}

#include "Engine.hpp"

// Here is a small helper for you! Have a look.
#include "ResourcePath.hpp"

int main(int, char const**)
{
   
    Engine engine;
    engine.gameLoop();
   
    return EXIT_SUCCESS;
}

Which is the main thread and which isnt? Is the thread classified by a function or by extra files?

3
General discussions / Re: How to use SFML without xcode on Mac?
« on: March 16, 2017, 05:27:40 pm »
Quote
How can i compile and link sfml to my main.cpp file?
You can have a look at the Linux tutorial for that.

But this is not specific to SFML, you'll have to do the same steps for any other library that you use, so you should rather read some good tutorial about the basics of gcc.

Yeah i know, i'd be using the gcc or g++ compiler, i was just wondering if anyone else here does it and what their tactic is for doing it.

4
General discussions / Re: How to use SFML without xcode on Mac?
« on: March 16, 2017, 05:26:48 pm »
You could use any of these on a Mac: Codeblocks, Eclipse C++ or CLion. There's a tutorial on using SFML in Codeblocks.

Which country are you studying Computer Science in?

Yeah but all those are IDEs, im trying to stay away from them. Im studying Computer Science in Portland, Oregon, USA.

5
General discussions / How to use SFML without xcode on Mac?
« on: March 16, 2017, 08:00:52 am »
I'm used to using IDEs and other software related tools. However, due to my previous computer science classes, i been enjoying using a simple text editor and a compiler.

So that been said im still relatively new to using the terminal (Mac Sierra OS).
How can i compile and link sfml to my main.cpp file?
any tips would be appreciated thanks.

I can compile a file and execute single files
g++ main.cpp -o main
./main

However, i dont know how to do it while having external Library

6
General / Having a hard time drawing a private sf::RectangleShape?
« on: February 14, 2015, 11:21:13 pm »
I'm trying to recreate another pong game. Why you might ask, well because as i learn C++ i'm learning better design, etc. I don't practice C++ regularly but more like once every 2 weeks because of school and work! So i would like some help and perhaps no hard comments. I've managed to make it work before but can't seem to remember! So this is what i'm doing:

1) created a class named Entities that contains a constructor with specific parameters properties for sf::RectangleShape, sf::Circle, etc.
2) I then created 4 variables of data type sf::RectangleShape, sf::Circle, etc. as private member variables.
3) i created 4 getFunctions that will return the variables.

Entities.h
#include <SFML/Graphics.hpp>
#include "ResourcePath.hpp"

class Entities
{
public:
    sf::RectangleShape rect;
    sf::CircleShape circle;
    sf::Text text;
    sf::Font font;
   
public:
    Entities();
    Entities(sf::Vector2f size, sf::Vector2f position, sf::Color color);
    Entities(int radius, sf::Vector2f position, sf::Color color);
    Entities(std::string message, int charSize, sf::Vector2f position, sf::Font font, sf::Color color);
   
    sf::RectangleShape getRectangle();
    sf::CircleShape getCircle();
    sf::Text getText();
    sf::Font getFont();
   
   
};
#endif /* defined(__PongClone__entities__) */
 

Entities.cpp

#include "entities.h"

Entities::Entities()
{
    font.loadFromFile(resourcePath() + "");
}

Entities::Entities(sf::Vector2f size, sf::Vector2f position, sf::Color color)
{
    rect.setSize(size);
    rect.setPosition(position);
    rect.setFillColor(color);
}
Entities::Entities(int radius, sf::Vector2f position, sf::Color color)
{
    circle.setRadius(radius);
    circle.setPosition(position);
    circle.setFillColor(color);
}
Entities::Entities(std::string message, int charSize, sf::Vector2f position, sf::Font font, sf::Color color)
{
    text.setString(message);
    text.setCharacterSize(charSize);
    text.setPosition(position);
    text.setFont(font);
    text.setColor(color);
}

 sf::RectangleShape Entities::getRectangle()
{
    return rect;
}
sf::CircleShape Entities::getCircle()
{
    return circle;
}
sf::Text Entities::getText()
{
    return text;
}

sf::Font Entities::getFont()
{
    return font;
}
 

Now i have another class which will create specific objects. For example, i created a leftpaddle object like this:
Entities leftPaddle(Entities(sf::Vector2f(100,100), sf::Vector2f(200,200), sf::Color::White));

I've got all that working but when i try to draw the object i get and error like this:
"invalid use of non-static data member 'rect'"

ive tried
window->draw(getRectangle().leftPaddle);

but none of it works, also sorry for the wrong programming lingo!

Thanks for anyone willing to help and for your time spent!

7
Window / Re: How to make window fixed size (cant be resized)?
« on: October 24, 2014, 09:28:17 am »
Do what the above user mention:

 
sf::RenderWindow window(sf::VideoMode(400,600), "Example", sf::Style::TitleBar);

everything that you dont provide from the style will not appear, in this case only the titlebar will appear. PS: i wrote that line of code fast, so if it mentions error, i apologies ahead of time!

8
Window / Re: Where to place Window and Events using xCode?
« on: October 24, 2014, 09:25:30 am »
I'm experienced in C++, i'm at an intermediate level in C++. I read the tutorial, were it mentions that
"Yep, that's true. Mac OS X just won't agree if you try to create a window or handle events in a thread other than the main one."

So at first, i was creating it in a seperate h/cpp file but then i was left wondering, must i only have the window and event in the main function and everything else in a seperate class? Just a curiosity!

9
Window / Where to place Window and Events using xCode?
« on: October 23, 2014, 09:27:26 pm »
were exactly do i place the events and window ? I'm using mac, xCode and was explicitly told to have both the event and the window together, but must they be together in the main.cpp function or can i place them in a class of its own in another .cpp file? Would that work, if i wanted to stay in 1 thread! !

10
SFML projects / Re: Dwell - A Retro Sandbox Survival MMO
« on: September 22, 2014, 02:22:52 am »
dang that illustration is amazing! Love the quality and great work guys, please let me know when its finish! Allow us SFML individuals to get an early Beta Access!

11
General / Using Code::Block For Linux?
« on: July 14, 2014, 03:05:05 am »
So i finally started on my Introduction to Linux, for my College Class! We were demanded to use a Virtual Machine with Linux but me been the person that i am, decided to install a fresh version of Linux Mint on an Unused Hard drive for my laptop! Now the thing is, i'm not 100% familiar with Linux nor Code::Block! I'm learning by little the world of linux and so far i love it! Now my first time using C::B! I was wondering, how can i make the SFML project have the update of SFML 2.1 rather than 1.6 and 2.0! How can i update it? Most of those projects dont have any updated libraries! How can i update all those libraries to they're most recent version of Programming !

Please be gentle with me and information! Thank You !!!!

12
SFML projects / Re: Anyone want to build a 2D game with me?
« on: June 30, 2014, 05:55:32 am »
Hey guys.

I am also interested in coding with someone, so if You don't mind i will be happy to join You :)
My Skype username is: arch1en. I have it also installed on smartphone so i might not always answer :)

Add me if your interested to code together !
skype AndreeU17

13
SFML projects / Re: Anyone want to build a 2D game with me?
« on: June 26, 2014, 06:16:20 am »
AndreeU17: are you still looking for someone ? Im working on a 2D rpg game, zelda like.
Got some basic things already done. My c++ is decent, trying out opengl a bit.

Yes i am still looking for a partner. Some partners i have added but most dont recontact with me or are busy. Give me your skype and well work on it :D I want to make a RPG game !

14
I understand, i'll work on it otherwise i might just keep using xCode and fix the syntax highlight problem im having, thanks !

15
General / Not sure how to install SFML into Eclipse CDT - Mac OS X
« on: June 21, 2014, 03:46:49 am »
I've been programming using xCode 5 in my macbook pro laptop. However, i've been looking into using the Eclipse CDT IDE for no real reason but personal use. How can i install the SFML Framework using Eclipse CDT in my MacBook Pro? Should or is the same as any of the tutorials this site offers or is there a total different process? I'm very curious and would appreciate the help !
Thanks

Pages: [1] 2 3 4