Transistion.to or something else....

I’m prototyping a PnC game.

I have my sprite animating and 8 directions so it looks like it will be walking ‘toward’ the touch on the screen.

I added transition.to() to move the character to the new touch point. Works fine except that since I have defined the transition time it appears to move faster when the touch delta is large.

I don’t see a way to say ‘tranisiton xx pixel per sec’ or some such to make it ‘walk’ at the same speed regardless of where it’s going

I could do a calc based on current x/y and new x/y and some constant to make the movement rate steady. Is there a better way I’m not seeing?

Perhaps I should use something else???

Thanks!

Gary

Thanks!

You don’t really need to perform any complex calculations. All you really need are the good old Pythagoras theorem to calculate the distance between the two points and a constant for the speed to multiply the distance with.

You could write a 4 line function that takes in the touch point’s x and y coordinates, then calculate the distance and finally set the transition, where the time is the distance multiplied by the constant.

 

Thanks! I get that.

I’m also wondering if transition.to() is the right solution.

Generically there have to be others out there in Corona land that have implemented PnC, taking into account stopping for obstacles, not going through the wrong path, etc.

So I’m wondering if transition.to() and it’s required code to move a character around the screen properly is the right choice.

Any thoughts?

Anyone out there want to share the easy solution?

??? Just had a thought… Are there any ‘templates’ for PnC? I’ll look around but if anyone knows of one, please let me know! 

thanks again for all responses!

Gary

I’m not sure about any point and click templates, but I would say that transition.to is the right solution, but you will need to calculate a series of points that a series of transitions will need to go through.

You may find this interesting: https://www.groebelsloot.com/2015/12/24/pathfinding-part-1/

I created something very close to this some time ago. The link contains a two part tutorial for creating a pathfinding for point and click games. It even has a link to the author’s source code, but it isn’t in lua.

My solution leaned on drawing lines for areas where the player couldn’t move to. Then, whenever the player pressed to move somewhere, I checked the line from the player’s coordinates to those of the touch and checked whether it intersected with any of the “out of bounds” lines. If there was an intersection, I would count how many intersections. Odd number meant that the move would end in the out of bounds area, whereas even number of intersections meant that the move would end within bounds. If the move was within bounds, I’d apply a similar pathfinding algorithm. If the move ended out of bounds, then I simply moved the character to the point of intersection.

Sounds like you may want to use an enterFrame listener. This will allow you to move your object at a fixed speed. You check each frame to see if you have reached your destination or not and if you haven’t, you move your object a little bit in the direction you want to move. 

Rob

Q: Just curious.  What is a PnC game?  I’m not familiar with that acronym and Google isn’t turning anything up.

Remember, always spell out the acronym first, then use it later.  Otherwise you’re assuming everyone who reads it knows what you mean.

Ahhh more reading of the post and I see someone understood you.  Point-And-Click.  Not sure PNC is an agreed upon (or common) acronym for that.

At least I’m on-board now. 

Gary,

Hi again.

I’m not aware of any Corona templates for this kind of game.

There are a number of Point-and-Click games I can reference which are all a bit different.  Can you list a few (at least) that are most representative of the interactions and mechanics you are hoping to achieve?

Knowing what you want to achieve specifically, I and others may be able to make further suggestions.

UPDATE : Oh, and regarding transitioning at a fixed rate, yes you’ll either have to do a vector calculation or use an enterFrame listener for movement instead.

UPDATE2:  If this game is using a top-down perspective, then you may want to use Jumper for your navigation determination.  It might seem a little like over-kill but it will greatly simplify obstacle avoidance, etc.

https://github.com/pancinteractive/Jumper

https://github.com/Yonaba/Jumper

Last post for a while… I promise.  (I love game mechanics questions).

The best way I can suggest to approach this is to:

  1. Come up with your overall game theme and story.

  2. Break down, identify, and list the mechanics of your game.

  3. Make mini-tests implementing each mechanic so you understand how it is done.

  4. Integrate your learnings into your game.

This way, if you get stuck on a mechanic, you can describe it to us and share a zip file with your mechanic test/template so we can look at it and help.

Thanks for all the replys, roaminggamer and rob.

I made a bad assumption about the PnC reference, sorry. I’ve had discussions with other game writers where the short hand is used. 

Yes, games like Space Quest, Leisure Suit Larry and more recently Primordiafrom Wormwood Studios.

Also ‘Grisly Manor’ by FireMaple games.

I’ve used the enterFrame for a classic Gato sub game prototype, so I’ll revisit that.

It seemed that transition.to() would be perfect to set the sprite in motion but I see now it’s a misuse of that function.

The game is an adventure PnC game where the User is a hero with his sidekick, moving around landscapes and buildings looking for clues and solving puzzles.

THere is also a whole genre of PnC games called HOS or ‘Hidden Object Story’ games that have puzzles where you have locate, well, hidden objects. -)

My game is more like Space Quest and Primordia.

My game will have multiple display layers so that the sprites can travel ‘behind’ boulders, trees, etc as well as in front of them.

Thanks for the responses, I’ll keep you up do date.

I’m sure I’ll have lots of more questions.

Gary

You don’t really need to perform any complex calculations. All you really need are the good old Pythagoras theorem to calculate the distance between the two points and a constant for the speed to multiply the distance with.

You could write a 4 line function that takes in the touch point’s x and y coordinates, then calculate the distance and finally set the transition, where the time is the distance multiplied by the constant.

 

Thanks! I get that.

I’m also wondering if transition.to() is the right solution.

Generically there have to be others out there in Corona land that have implemented PnC, taking into account stopping for obstacles, not going through the wrong path, etc.

So I’m wondering if transition.to() and it’s required code to move a character around the screen properly is the right choice.

Any thoughts?

Anyone out there want to share the easy solution?

??? Just had a thought… Are there any ‘templates’ for PnC? I’ll look around but if anyone knows of one, please let me know! 

thanks again for all responses!

Gary

I’m not sure about any point and click templates, but I would say that transition.to is the right solution, but you will need to calculate a series of points that a series of transitions will need to go through.

You may find this interesting: https://www.groebelsloot.com/2015/12/24/pathfinding-part-1/

I created something very close to this some time ago. The link contains a two part tutorial for creating a pathfinding for point and click games. It even has a link to the author’s source code, but it isn’t in lua.

My solution leaned on drawing lines for areas where the player couldn’t move to. Then, whenever the player pressed to move somewhere, I checked the line from the player’s coordinates to those of the touch and checked whether it intersected with any of the “out of bounds” lines. If there was an intersection, I would count how many intersections. Odd number meant that the move would end in the out of bounds area, whereas even number of intersections meant that the move would end within bounds. If the move was within bounds, I’d apply a similar pathfinding algorithm. If the move ended out of bounds, then I simply moved the character to the point of intersection.

Sounds like you may want to use an enterFrame listener. This will allow you to move your object at a fixed speed. You check each frame to see if you have reached your destination or not and if you haven’t, you move your object a little bit in the direction you want to move. 

Rob

Q: Just curious.  What is a PnC game?  I’m not familiar with that acronym and Google isn’t turning anything up.

Remember, always spell out the acronym first, then use it later.  Otherwise you’re assuming everyone who reads it knows what you mean.

Ahhh more reading of the post and I see someone understood you.  Point-And-Click.  Not sure PNC is an agreed upon (or common) acronym for that.

At least I’m on-board now. 

Gary,

Hi again.

I’m not aware of any Corona templates for this kind of game.

There are a number of Point-and-Click games I can reference which are all a bit different.  Can you list a few (at least) that are most representative of the interactions and mechanics you are hoping to achieve?

Knowing what you want to achieve specifically, I and others may be able to make further suggestions.

UPDATE : Oh, and regarding transitioning at a fixed rate, yes you’ll either have to do a vector calculation or use an enterFrame listener for movement instead.

UPDATE2:  If this game is using a top-down perspective, then you may want to use Jumper for your navigation determination.  It might seem a little like over-kill but it will greatly simplify obstacle avoidance, etc.

https://github.com/pancinteractive/Jumper

https://github.com/Yonaba/Jumper

Last post for a while… I promise.  (I love game mechanics questions).

The best way I can suggest to approach this is to:

  1. Come up with your overall game theme and story.

  2. Break down, identify, and list the mechanics of your game.

  3. Make mini-tests implementing each mechanic so you understand how it is done.

  4. Integrate your learnings into your game.

This way, if you get stuck on a mechanic, you can describe it to us and share a zip file with your mechanic test/template so we can look at it and help.

Thanks for all the replys, roaminggamer and rob.

I made a bad assumption about the PnC reference, sorry. I’ve had discussions with other game writers where the short hand is used. 

Yes, games like Space Quest, Leisure Suit Larry and more recently Primordiafrom Wormwood Studios.

Also ‘Grisly Manor’ by FireMaple games.

I’ve used the enterFrame for a classic Gato sub game prototype, so I’ll revisit that.

It seemed that transition.to() would be perfect to set the sprite in motion but I see now it’s a misuse of that function.

The game is an adventure PnC game where the User is a hero with his sidekick, moving around landscapes and buildings looking for clues and solving puzzles.

THere is also a whole genre of PnC games called HOS or ‘Hidden Object Story’ games that have puzzles where you have locate, well, hidden objects. -)

My game is more like Space Quest and Primordia.

My game will have multiple display layers so that the sprites can travel ‘behind’ boulders, trees, etc as well as in front of them.

Thanks for the responses, I’ll keep you up do date.

I’m sure I’ll have lots of more questions.

Gary