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

Pages: [1]
1
Graphics / Re: Strange Title Bar Text
« on: April 07, 2012, 10:41:28 pm »
*facepalm*, that fixed it, thanks to both of you!

2
Graphics / Re: Strange Title Bar Text
« on: April 07, 2012, 09:09:24 pm »
The title I give it appears, but the weird characters still appear to the left of it when I initalized the object like:
Code: [Select]
App(sf::VideoMode(ScreenWidth, ScreenHeight, 32),
  std::string("Snake"), sf::Style::Close),

I'm using Visual Studio 2010, by the way.

3
Graphics / Strange Title Bar Text
« on: April 07, 2012, 08:49:38 pm »
Hey guys, I know this is a common problem, but having researched it some I still haven't been able to find a fix.  Basically I'm just getting lots of BS characters in my titlebar text.  I initialized my RenderWindow like this:
Code: [Select]
App(sf::VideoMode(ScreenWidth, ScreenHeight, 32), std::string(), sf::Style::Close)For some reason the titlebar text looks like this: http://imageshack.us/photo/my-images/11/photour.png/

So can anyone help me fix this?  Thanks!

4
Graphics / Noob Troubles on Snake
« on: March 30, 2012, 09:33:27 pm »
hey guys, so I've started delving into the world of Game Development and learning SFML.  My first experiences weren't that bad, but now I'm running into some n00by troubles on my first attempt at a game (which is essentially just Snake).  My trouble is with my function AddNode(), which is supposed to add a new node to the snake (as in whenever they eat food).  The node is being added, and rendered properly, but it's new coordinates are off.  So could someone help me out with this?  I thought I was calculating the new coordinates properly, but I guess I'm not. 

So here's the relevant code.  If you want me to post more, I'll be happy too, thanks!
AddNode()
Code: [Select]
#define LASTNODE nodes[nodes.size()-1]
Snake::Node *Snake::AddNode()
{
Node *NewNode;
switch (LASTNODE->GetDirection()) {
case Node::LEFT:
// 10 is the width and height of each node, I'm just currently too lazy to replace it
// with a const
NewNode = new Node(LASTNODE->GetShape().GetPosition().x+10,
   LASTNODE->GetShape().GetPosition().y,
   LASTNODE->GetShape().GetPosition().x+20,
   LASTNODE->GetShape().GetPosition().y+10);
nodes.push_back(NewNode);
NewNode->SetDirection(Node::LEFT);
break;
case Node::RIGHT:
NewNode = new Node(LASTNODE->GetShape().GetPosition().x-10,
   LASTNODE->GetShape().GetPosition().y,
   LASTNODE->GetShape().GetPosition().x-20,
   LASTNODE->GetShape().GetPosition().y-10);
nodes.push_back(NewNode);
NewNode->SetDirection(Node::RIGHT);
break;
case Node::UP:
NewNode = new Node(LASTNODE->GetShape().GetPosition().x,
   LASTNODE->GetShape().GetPosition().y+10,
   LASTNODE->GetShape().GetPosition().x+10,
   LASTNODE->GetShape().GetPosition().y+20);
nodes.push_back(NewNode);
NewNode->SetDirection(Node::UP);
break;
case Node::DOWN:
NewNode = new Node(LASTNODE->GetShape().GetPosition().x,
   LASTNODE->GetShape().GetPosition().y-10,
   LASTNODE->GetShape().GetPosition().x+10,
   LASTNODE->GetShape().GetPosition().y-20);
nodes.push_back(NewNode);
NewNode->SetDirection(Node::DOWN);
break;
}
return NewNode;
}
Node Constructor:
Code: [Select]
Snake::Node::Node(float x1, float y1, float x2, float y2)
: shape(sf::Shape::Rectangle(x1, y1, x2, y2, sf::Color(100, 100, 100)))
{ }
Node Interface (which is nested in the Snake class)
Code: [Select]
class Node {
public:
enum Direction { LEFT, RIGHT, UP, DOWN };

Node(float, float, float, float); // constructor
void Update(sf::RenderWindow &App, sf::Event &Event);

Direction GetDirection() const { return direction; }
sf::Shape &GetShape() const { return shape; }

void SetDirection(Node::Direction direc) { direction = direc; }
private:
sf::Shape shape;
void Move(float ElapsedTime);
// Direction
Direction direction;
void Direction(sf::RenderWindow&, sf::Event&);
};

5
Graphics / Cannot Access Private Member in class "sf::NonCopyable&
« on: June 19, 2011, 08:47:02 pm »
EDIT: Fixed it!  Nevermind!

The move code is in the original post.  Here it is again:
Code: [Select]

enum Direction { left, right, up, down };

class CMove
{
public:
CMove(sf::Shape& obj)
: object(&obj)
{ }
void WalkLeft() // walk left
{
dir = left;
Walk(dir);
}
void WalkRight() // walk right
{
dir = right;
Walk(dir);
}
void WalkUp() // walk up
{
dir = up;
Walk(dir);
}
void WalkDown() // walk down
{
dir = down;
Walk(dir);
}
private:
Direction dir; // the direction to move in
sf::Shape* object; // pointer to the object to move
void Walk(Direction dir) const; // move the object
};

// move the player in the direction specified in dir
void CMove::Walk(Direction dir) const
{
switch(dir)
{
case left:
object->Move(-5, 0);
case right:
object->Move(5, 0);
case up:
object->Move(0, -5);
case down:
object->Move(0, 5);
}
return;
}


As for it being a poltergeist class I moved the instantiation of the Move object outside of the main loop so it's only instantiated once.  The main function looks like this now:
Code: [Select]

#include<SFML/Graphics.hpp>
#include<iostream>
#include "Move.h"

void handleMovement(const sf::Input& Input, CMove* Move) // handle movement of player
{
bool leftKey = Input.IsKeyDown(sf::Key::Left);
bool rightKey = Input.IsKeyDown( sf::Key::Right);
bool upKey = Input.IsKeyDown(sf::Key::Up);
bool downKey = Input.IsKeyDown(sf::Key::Down);
if(leftKey)
Move->WalkLeft();
if(rightKey)
Move->WalkRight();
if(upKey)
Move->WalkUp();
if(downKey)
Move->WalkDown();
}

int main(void)
{
sf::RenderWindow App(sf::VideoMode(800, 640, 32), "SFML Window");
App.SetFramerateLimit(60);

sf::Shape rect = sf::Shape::Rectangle(300, 300, 350, 350, sf::Color(200, 200, 200));
CMove Move(rect);
CMove* pMove = &Move;
while(App.IsOpened())
{
sf::Event Event;
const sf::Input& Input = App.GetInput();
while(App.GetEvent(Event))
{
// handle movement
handleMovement(Input, pMove);

if(Event.Type == sf::Event::Closed)
App.Close();
}

App.Clear();
App.Draw(rect);
App.Display();
}


return EXIT_SUCCESS;
}

6
Graphics / Cannot Access Private Member in class "sf::NonCopyable&
« on: June 19, 2011, 08:34:22 pm »
Any help on this?  I can't figure out why the hell only right and down are working.

If it helps here's my main function:
Code: [Select]

#include<SFML/Graphics.hpp>
#include<iostream>
#include "Move.h"

void handleMovement(sf::Shape& object, const sf::Input& Input)
{
CMove Move(object);
bool leftKey = Input.IsKeyDown(sf::Key::Left);
bool rightKey = Input.IsKeyDown( sf::Key::Right);
bool upKey = Input.IsKeyDown(sf::Key::Up);
bool downKey = Input.IsKeyDown(sf::Key::Down);
if(leftKey)
Move.WalkLeft();
if(rightKey)
Move.WalkRight();
if(upKey)
Move.WalkUp();
if(downKey)
Move.WalkDown();
}

int main(void)
{
sf::RenderWindow App(sf::VideoMode(800, 640, 32), "SFML Window");
App.SetFramerateLimit(60);

sf::Shape rect = sf::Shape::Rectangle(300, 300, 350, 350, sf::Color(200, 200, 200));
while(App.IsOpened())
{
sf::Event Event;
const sf::Input& Input = App.GetInput();
while(App.GetEvent(Event))
{
// handle movement
handleMovement(rect, Input);

if(Event.Type == sf::Event::Closed)
App.Close();
}

App.Clear();
App.Draw(rect);
App.Display();
}


return EXIT_SUCCESS;
}

7
Graphics / Cannot Access Private Member in class "sf::NonCopyable&
« on: June 19, 2011, 07:54:41 pm »
Bleh, stupid me.  In my main function when I was declaring my variable for storing input I forgot to make it a const reference, so it was trying to make a copy of the input I guess  -_-  Fixed now, however now for some reason the player can only walk right and down, I'll have to work on that :/

8
Graphics / Cannot Access Private Member in class "sf::NonCopyable&
« on: June 19, 2011, 07:31:07 pm »
Hey guys!  I started learning SFML and was screwing around trying to get a movement class to work, but I keep getting a compiler error I just don't understand.  The error is:
'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
1>        c:\sfml-1.6\include\sfml\system\noncopyable.hpp(57) : see declaration of 'sf::NonCopyable::NonCopyable'
1>        c:\sfml-1.6\include\sfml\system\noncopyable.hpp(41) : see declaration of 'sf::NonCopyable'

My definition of the Move class is as follows:
Code: [Select]

#pragma once
#include<SFML/Graphics.hpp>

enum Direction { up, down, left, right };

class CMove
{
public:
CMove(sf::Shape& obj)
: object(&obj)
{ }

void WalkLeft() // walk left
{
dir = left;
Walk(dir);
}
void WalkRight() // walk right
{
dir = right;
Walk(dir);
}
void WalkUp() // walk up
{
dir = up;
Walk(dir);
}
void WalkDown() // walk down
{
dir = down;
Walk(dir);
}
private:
Direction dir; // the direction to move in
sf::Shape* object; // pointer to the object to move
void Walk(Direction Dir) const; // move the object
};

// move the player in the direction specified in dir
void CMove::Walk(Direction dir) const
{
switch(dir)
{
case up:
object->Move(0, -2);
case down:
object->Move(0, 2);
case left:
object->Move(2, 0);
case right:
object->Move(-2, 0);
}
return;
}


Thanks!

Pages: [1]
anything