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

Pages: [1] 2
1
Graphics / Simulating Window-Border Collision!
« on: August 05, 2011, 11:17:53 pm »
Edited:

Hmm, couldn't convert from sf::sprite to sf::shape, so I replaced the function parameter with sf::sprite instead, and removed the ampersand sign.

My sprite effectively stops at the border... But then becomes unresponsive  :(

Did i change too much?

Code: [Select]

//the function
bool locationAllowed(sf::Sprite sprite) {
sf::Vector2f temp = sprite.GetPosition();
int x = temp.x + 1;
int y = temp.y + 1;
if (x > 800 || x < 0) {
   return false;
}
if (y > 600 || y < 0) {
   return false;
}
return true;
}



Code: [Select]

if (LeftKeyDown  && locationAllowed(Blob))
            Blob.Move(-KeyMove, 0);
         if (RightKeyDown && locationAllowed(Blob))
            Blob.Move(KeyMove, 0);
         if (UpKeyDown  && locationAllowed(Blob))
            Blob.Move(0, -KeyMove);
         if (DownKeyDown  && locationAllowed(Blob))
            Blob.Move(0, KeyMove);
         if (GKeyDown  && locationAllowed(Blob))
            Blob.Rotate(KeyMove);
         if (HKeyDown  && locationAllowed(Blob))
            Blob.Rotate(-KeyMove);

2
Graphics / Simulating Window-Border Collision!
« on: August 05, 2011, 09:02:20 pm »
Hey!

Got this tiny 'lil problem now... I'm trying to keep my moving sprite from going outside the window borders, currently using:

Code: [Select]

float KeyMove = 0.10f;

sf::FloatRect BorderColl(0, 0, 800, 600);
sf::Vector2f BlobPosition = Blob.GetPosition();
bool CheckBorderColl = BorderColl.Contains(BlobPosition);
if (CheckBorderColl == 1);
{
if (ShiftKeyDown)
KeyMove = 0.3f;

if (LeftKeyDown)
Blob.Move(-KeyMove, 0);
if (RightKeyDown)
Blob.Move(KeyMove, 0);
if (UpKeyDown)
Blob.Move(0, -KeyMove);
if (DownKeyDown)
Blob.Move(0, KeyMove);
if (GKeyDown)
Blob.Rotate(KeyMove);
if (HKeyDown)
Blob.Rotate(-KeyMove);
}

Win.Clear();
Win.Draw(Blob);
Win.Display();

}


I originally had it as
Code: [Select]
while (CheckBorderColl)

but that froze the program as soon as it executed... Umm, am I using the wrong functions for checking this, any ideas?

3
Graphics / Simulating character movement - How do? [SOLVED]
« on: July 22, 2011, 04:52:38 pm »
Ah, that's great advice, more control over movement  :)

Disch, as in, disch from cplusplus?

4
General discussions / List of modifications from SFML 1.6 to 2.0
« on: July 22, 2011, 01:30:42 pm »
Quote
sf::Input -> sf::Joystick, sf::Keyboard, sf::Mouse (directly connected to the OS rather than to sf::Event)


I thought I was using SFML 2.0, or are these simply not implemented in the build I am using?

5
SFML projects / iCEĀ³ - clone of Minecraft
« on: July 22, 2011, 01:06:08 pm »
Very interesting, and great work to you, good sir.

6
Graphics / Simulating character movement - How do? [SOLVED]
« on: July 22, 2011, 01:03:41 pm »
Ah, thank you G.!

7
Graphics / Simulating character movement - How do? [SOLVED]
« on: July 22, 2011, 11:57:30 am »
Hmm, okay.

Code: [Select]

while (Win.IsOpened())
{
const sf::Input& Input = Win.GetInput();
bool LeftKeyDown = Input.IsKeyDown(sf::Key::A);
bool RightKeyDown = Input.IsKeyDown(sf::Key::D);
bool UpKeyDown = Input.IsKeyDown(sf::Key::W);
bool DownKeyDown = Input.IsKeyDown(sf::Key::S);


sf::Clock WinTime;
float Timer = WinTime.GetElapsedTime();


sf::Event Happen;
while (Win.PollEvent(Happen))
{
switch (Happen.Type)
{
case sf::Event::Closed:
Win.Close();
break;
case sf::Event::KeyPressed:
if (Happen.Key.Code == sf::Key::Escape)
Win.Close();
break;
default:
break;
}
}

if (LeftKeyDown)
Head.Move(-0.1, 0);
if (RightKeyDown)
Head.Move(0.1, 0);
if (UpKeyDown)
Head.Move(0, -0.1);
if (DownKeyDown)
Head.Move(0, 0.1);

Win.Clear();
Win.Draw(Head);
Win.Display();

}
}


So that's what I've got then, and pressing any key just removes the sprite, although the window is still responsive.


Edit: Changed the (move's) to 1's instead of 10's, and it's now moving around REALLY fast???

This is slightly confusing.

Edit2: Changed it to 0.1 movements instead, and it's working perfectly now!

So uh... Nice, I guess  :)

8
SFML projects / A Box2D x SFML proof of concept
« on: July 21, 2011, 09:13:04 pm »
Wow... This looks great, I would definetly play (maybe even pay) this game.

9
Graphics / Simulating character movement - How do? [SOLVED]
« on: July 21, 2011, 09:09:54 pm »
Ah, Okay, Thanks Laurent! So I made it into if expressions again and moved it into the PollEvent loop.

It seems to work differently... But, still a delay before movement when actually starting to press the key.

So, this is the current state:

Code: [Select]

while (Win.IsOpened())
{
const sf::Input& Input = Win.GetInput();
bool LeftKeyDown = Input.IsKeyDown(sf::Key::A);
bool RightKeyDown = Input.IsKeyDown(sf::Key::D);
bool UpKeyDown = Input.IsKeyDown(sf::Key::W);
bool DownKeyDown = Input.IsKeyDown(sf::Key::S);


sf::Clock WinTime;
float Timer = WinTime.GetElapsedTime();


sf::Event Happen;
while (Win.PollEvent(Happen))
{
if (LeftKeyDown)
Head.Move(-10, 0);
if (RightKeyDown)
Head.Move(10, 0);
if (UpKeyDown)
Head.Move(0, -10);
if (DownKeyDown)
Head.Move(0, 10);


And then it moves onto the event switch for closing the window and whatnot...


So, uh... The clock is completely unused.  
I'm still not sure where to go from here to get the smooth movement I want  :)

10
Graphics / Simulating character movement - How do? [SOLVED]
« on: July 21, 2011, 05:35:06 pm »
:oops:

Oh my god, sorry about that!

Right okay, I'm at a loss right now aswell though, I figured I'd move my Input checking here:

Code: [Select]

while (Win.IsOpened())
{
const sf::Input& Input = Win.GetInput();
bool LeftKeyDown = Input.IsKeyDown(sf::Key::A);
bool RightKeyDown = Input.IsKeyDown(sf::Key::D);
bool UpKeyDown = Input.IsKeyDown(sf::Key::W);
bool DownKeyDown = Input.IsKeyDown(sf::Key::S);

while ()
{
Head.Move(-10, 0);
}


I was thinking this would work, but apparently it doesn't. Infact, it actually freezes the program.
Code: [Select]

while (LeftKeyDown)
{
Head.Move(-10, 0);
}


However, I'm not sure where to go from here to check the Realtime Input, any advice?

11
Graphics / Simulating character movement - How do? [SOLVED]
« on: July 21, 2011, 05:10:18 pm »
Hey!

So, I've managed to get together a blob that moves around the screen with the WASD keys, by this code:

Code: [Select]

const sf::Input& Input = Win.GetInput();
bool LeftKeyDown = Input.IsKeyDown(sf::Key::A);
bool RightKeyDown = Input.IsKeyDown(sf::Key::D);
bool UpKeyDown = Input.IsKeyDown(sf::Key::W);
bool DownKeyDown = Input.IsKeyDown(sf::Key::S);


And then later down the switch (Event.Type) this:
(Head is the sprite I want to control movement with)
Code: [Select]

case sf::Event::KeyPressed:
if (UpKeyDown)
Head.Move(0, -10);
if (DownKeyDown)
Head.Move(0, 10);
if (RightKeyDown)
Head.Move(10, 0);
if (LeftKeyDown)
Head.Move(-10, 0);


Now, this works to a degree, using the sf::Input i can press up and right  at the same time and it'll go diagonal. (Whereas i just had KeyPressed before)

However, upon pressing for example W (to go up) it moves one step (10 pixels) then stops for about half a second, then continues relatively smooth.

I guess I should use the clock somehow and decrease the Move to maybe 1 pixel per 0.1 seconds or something, so that I can get the smooth movement I want.

Just not sure how to go about this, any ideas?

Also, sorry if this is in the wrong section.

12
General / Visual Studio 2010 Express Problems [SOLVED]
« on: July 03, 2011, 12:22:16 am »
That makes sense, thanks!

13
General / Visual Studio 2010 Express Problems [SOLVED]
« on: July 01, 2011, 01:26:45 pm »
Ah, excellent. But then why don't we use static libraries all the time?

Size, compiler time, licketylicketyboomboom?

14
General / Visual Studio 2010 Express Problems [SOLVED]
« on: June 30, 2011, 11:58:39 pm »
Ah, so Debug it is then :3

I can't wrap my head around how static enables development without the DLLs :s

15
General / Visual Studio 2010 Express Problems [SOLVED]
« on: June 30, 2011, 05:55:36 pm »
One thing I would love is an indepth but easy to understand explanation as to the differences about release/debug and static/dynamic and the scenarios in which either should be applied  :)

Pages: [1] 2