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

Pages: [1]
Window / [SOLVED]Resizing the Window
« on: January 24, 2014, 12:04:32 am »
I am using the sf::CircleShape to create hexagons. However I want the user to be able to resize the window but when I do that the hexagons change their size. What can I do to prevent this from happen?

General / Point position relative to Window
« on: November 23, 2013, 11:54:25 pm »
So I am working with hexagons and the easiest way I found to do this with SFML is set a CircleShape point count to 6. But now I'm implementing a mouse check and I needed the points position but the getPoint() function gives me the position relative to the hexagon bounding rect instead of giving the position relative to the Window. So my question is:

How do I get the point position relative to the window?

General / An Hexagon Rect
« on: November 17, 2013, 02:17:38 pm »
Okay so I've seen the Rect.inl file and understood what was going on for the rect/squares but because I'm in 8th grade I don't know how to do the same for an hexagon, I just don't know the mathematical form for it. So if someone could guide me through it.

Lots of thanks, lockandstrike

System / isKeyPressed() function not working
« on: November 12, 2013, 11:19:43 am »
So I'm building a game and it requires keyboard input. For some reason god know why the events didn't work so i moved on to the isKeyPressed function and it does not work at all. The code is bellow. Can some one please tell me what is wrong with my code?


#ifndef HEXGRID_HPP_
#define HEXGRID_HPP_

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

class HexGrid {

        HexGrid(int height, int width, float radius, sf::Color color);
        void draw(sf::RenderWindow &App);


        sf::CircleShape hexagon;
        sf::Color defColor;
        int defHeight;
        int hexNumber;
        int defWidth;
        int yRow;
        float defRadius;
        float xPos;
        float yPos;
    float yKeyPos;
    float xKeyPos;

    sf::Vector2f keyPos;
        sf::FloatRect hexBounds;




#include "HexGrid.hpp"

HexGrid::HexGrid(int height, int width, float radius, sf::Color color){

        defHeight = height;
        defWidth = width;
        defRadius = radius;
        defColor = color;
        hexNumber = width * height;
        yRow = 1;


void HexGrid::draw(sf::RenderWindow &App){

        //sf::Vector2f poshex = hexagon.getPoint(2);

        xPos = hexagon.getRadius();
        yPos = hexagon.getRadius();
        // xKeyPos = hexagon.getRadius();
        // yKeyPos = hexagon.getRadius();

        for(int i = 1; i <= hexNumber; ++i){
                hexagon.setPosition(xPos, yPos);

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up) == true)
            yKeyPos = yKeyPos - ( hexagon.getRadius() * 2 );
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down) == true)
            yKeyPos = yKeyPos + ( hexagon.getRadius() * 2);
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right) == true)
            xKeyPos = xKeyPos + ( hexagon.getRadius() * 2);
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left) == true)
            xKeyPos = xKeyPos - ( hexagon.getRadius() * 2);
                hexBounds = hexagon.getGlobalBounds();
        keyPos = sf::Vector2f(xKeyPos,yKeyPos);

                if( i % defWidth == 0 && i != 0 ){
                        if (yRow % 2 == 0){
                                xPos = hexagon.getRadius();
                                yPos += hexagon.getRadius() * 1.6;
                xPos = hexagon.getRadius() * 1.822;
                                yPos += hexagon.getRadius() * 1.6;


                        xPos += hexagon.getRadius() * 1.82;

        if( hexBounds.contains(keyPos) ){




#include "HexGrid.hpp"

int main(){
        sf::RenderWindow app(sf::VideoMode(800,600,32),"Tyrion: TCoW");

        HexGrid hex(10,10,30.f,sf::Color(250,0,0));

                sf::Event evt;
                        if(evt.type == sf::Event::Closed)


                //HexGrid(5, 5, 30, sf::Color(50,50,50),app);

        return 0;

Graphics / [SOLVED]Loading charset
« on: August 08, 2013, 04:29:50 pm »
So I'm doing this project and for my character sprite i'll be using an RPG Maker charset. For my project more understandable i've got it divided in functions. When i load the png file that contains my charset it doesnt show anything. It goes like an enormous white square. Here's the code:

#include <SFML/Graphics.hpp>

sf::Texture loadStuff()
          sf::Texture gmChar;

                  //return EXIT_FAILURE;
                  return gmChar;


void defCharset(sf::Sprite *gmCharacther_semiIdle, sf::Sprite *gmCharachter_stage1, sf::Sprite *gmCharachter_stage2)

  sf::Texture gmChar;

  gmChar = loadStuff();



so after the blank square i tried putting it all in the same function. But with that the game didn't even start. Here's the code for that:

#include <SFML/Graphics.hpp>

void defCharset(sf::Sprite *gmCharacther_semiIdle, sf::Sprite *gmCharachter_stage1, sf::Sprite *gmCharachter_stage2)

  sf::Texture gmChar;

     //return EXIT_FAILURE;



PS: This is only part of the program. I think it's obvious but...

Graphics / Flashing Text
« on: August 06, 2013, 08:13:17 pm »
So hi. I'm starting my game and I'm doing the menu. I've decided the way I'm going images for the background and text for the actual button. So what i would like is when the user is going through the menu with the arrow keys the button witch is currently selecting is highlighted. The highlight would be the text flashing. By flashing I mean switching between 2 colors. I have no idea how to so any help is tremendously appreciated.  ;)

General / [SOLVED] Help with a switch statement
« on: August 06, 2013, 05:06:49 pm »
So here is the thing. I'm starting to learn SFML and although i know C++ there are somethings that i still don't possess total knowledge of. So here the part of my code where I need help:

switch (event.type || event.key.code ){

case sf::Keyboard::Escape:
case sf::Event::Closed:


But when i run the program with this code it doesn't allow me to close it neither with the close button neither with the escape key.
Any help would be appreciated.

Pages: [1]