Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


rijvgt

Member Since 29 Aug 2013
Offline Last Active Sep 20 2013 03:20 PM

Posts I've Made

In Topic: setting the displacement between snake segments

30 August 2013 - 09:46 AM

 

I have done all things, but still the offset is not correctly set. This is the whole code:

 

I have updated my post. Gl smile.png


In Topic: setting the displacement between snake segments

30 August 2013 - 06:56 AM



My question is about the offset between the body of the segements. How to set it ?

 

Your current loop is wrong...

 


in each loop the only node that gets updated properly is the nodes[1] the rest will get older values(each loop will update nodes[i] with nodes[i-1]'s previous value instead of nodes[i-1]) because you loop from the bottom of the snake instead of it's head. (If your snake would stopped moving, after nodes.size() amount of frames the snake would get back together)

 

In case you want support with anything above your posted code you should also include it in your post.


In Topic: SFML Directory or File not found

29 August 2013 - 06:16 PM

 

The problem isn't related to SFML. I think you should #include "ScreenManager.h" in your main instead of the cpp cause (even if it didn't pop error)-logically that's your class definition and where creating an object should apply.

 

Hope I helped and goodluck with your game =]

 

//Haven't used it yet but FLARE (rpg) game engine could be helpful in case you're a novice like me, it seems clean and awesome. smile.png

 

I changed it to <ScreenManager.h> but it still gives me the same error

 

Mhh you havent posted the file where you implement the screenmanager... but you can see examples from the flare engine on what you are trying to achieve. Even if it has nothing to do with the fact that you're both using SFML, they seem to be following C++ standards.

 

For example you can see the #include "GameSwitcher.h" in the main https://github.com/clintbellanger/flare-engine/blob/master/src/main.cpp

 

And how it is implemented:

https://github.com/clintbellanger/flare-engine/blob/master/src/GameSwitcher.h

https://github.com/clintbellanger/flare-engine/blob/master/src/GameSwitcher.cpp


In Topic: SFML Directory or File not found

29 August 2013 - 05:16 PM

The problem isn't related to SFML. I think you should #include "ScreenManager.h" in your main instead of the cpp cause (even if it didn't pop error)-logically that's your class definition and where creating an object should apply.

 

Hope I helped and goodluck with your game =]

 

//Haven't used it yet but FLARE (rpg) game engine could be helpful in case you're a novice like me, it seems clean and awesome. smile.png


In Topic: setting the displacement between snake segments

29 August 2013 - 05:00 PM

Could you explain how exactly the body of the snake gets distorted?

 

In case the snake is constantly moving, in each loop the only node that gets updated properly is the nodes[1] the rest will get older values(each loop will update nodes[i] with nodes[i-1]'s previous value instead of nodes[i-1]) because you loop from the bottom of the snake instead of it's head. (If your snake would stopped moving, after nodes.size() amount of frames the snake would get back together)

No, that's the way it is supposed to be happy.png but you're wasting the first node.size()-1 repeats of the loop/frame

 

In your code you have setted c.vy = 0; so when you use circles[0].yPosition-=circles[0].vy*(2*5); it doesnt really do anything cause this is always circles[0].yPosition-=0. 

 

So you are currently only moving horrizontally.

 

 

Moreover, the following loop wouldn't work with the way you update the circles[0]'s position: (The circles wouldnt stay chainned)

 

for ( var i:int =4; i>0; i--)

{

                circles[i].xPosition = circles[i-1].xPosition;

                circles[i].yPosition = circles[i-1].yPosition;

}

 

// update circles[0] position

 

 

To fix the current way you handle the snake's head movement, try doing something like this: (Haven't tested it and it IS missing cases)

 

//update circles[0] position anyhow.

circles[0].xPosition-=circles[0].vx*(2*5);
circles[0].yPosition-=circles[0].vy*(2*5);

 

// Submit the changed position properly to the rest of the circles.

for (int i=1; i<5; i++)

{

if (circles[i].yPosition != circles[i-1].yPosition)

{

if (circles[i].xPosition != circles[i-1].xPosition)

circles[i].xPosition = circles[i-1].xPosition;

 

circles[i].yPosition-=( circles[i].vy*(2*5) - (the diameter of the circle)*i);

}

else {

circles[i].xPosition-=circles[i].vx*(2*5); //apply the same you used on circles[0]

}

 

}

 

 

Incase I'm wrong and that doesnt work dry.png, I would maybe advise you to control your FPS value(ie. lower it to like 1-5 in some cases), I think it would be easier to spot these kind of problems.


PARTNERS