[Java] Pokémon Walking algorithm

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,260
Update (May 19, 2020):
The project is now active. Thanks to COVID-19, the quarantine period helped me stay focused on this project.


Update (September 26, 2016):

The project is still on hold, because the most important thing you need to do in life is to get a decent well-paid job, else you starve yourself. Once everything is settled down, I will then be able to continue on other projects I have left behind.


Update (February 4, 2015):

For those who reads this post, please be sure to actually visit this Github project page for the latest news and whereabouts. Currently, the project is on hold, as education has super-max priority.

__________________________________________________________________

Github Homepage: https://github.com/tommai78101/PokemonWalking


I have created a Java game program that mimics the protagonist's walking logic. Attached below is the Java source code and the runnable JAR file for testing purposes. Unzip "walking.zip" and extract the JAR file, then run the JAR file.

I seemed to have polished it to the point that I feel it's perfect the way it is right now, and it's worthy of a release at this point.

Please, take a look. Feedback is appreciated.
 

Attachments

Last edited:

Accname

2D-Graphics enthusiast
Reaction score
1,457
Yeah. It really feels like pokemon. But i wouldnt say that the way the movement in pokemon felt like was something positive.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,260
Yeah. It really feels like pokemon. But i wouldnt say that the way the movement in pokemon felt like was something positive.
It's easy to navigate, and it's simple when you're constructing an RPG world. I even think the Legend of Zelda NES games have this walking logic implemented before Pokémon ever came known.

I'm still tinkering with the latency for firing off the KeyEvents.
 

camelCase

The Case of the Mysterious Camel.
Reaction score
358
Lots of old-school RPGs implemented this kind of walking mechanic.
It makes collision detection soooo easy xD

Good job; gotta' fix that delay, though.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,260
Lots of old-school RPGs implemented this kind of walking mechanic.
It makes collision detection soooo easy xD

Good job; gotta' fix that delay, though.
That delay is somewhat the limitations of the Java AWT KeyEvents. When it's running at a constant 60FPS, just 1 tick alone is all it takes to get it to acceptable standards. Any more ticks than that will lag tremendously.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,260
I've fixed the issue with the background being clipped as a gray border surrounding the "grid-like grass tiles". I've also edited the grass tiles, so that it will display nicer-looking grids for visual aid.

No collision detection available, though.

The issue with the AWT KeyEvent latencies are still there. It's unfixable by design (AWT Java stuffs).
 

Attachments

Accname

2D-Graphics enthusiast
Reaction score
1,457
If you want to seriously work on a java game i would highly recommend using openGL and different libraries to the standard java stuff.
There is good material out there: JOGL, lwjgl, etc.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,260
If you want to seriously work on a java game i would highly recommend using openGL and different libraries to the standard java stuff.
There is good material out there: JOGL, lwjgl, etc.
Hm? I never said this is going to become an actual full-blown game. I did this in order to learn how to re-create the walking used in old-school NES / GBC RPGs.

P.S.: The intended purpose for this "game" is to teach people how to implement a walking algorithm, like an on-hands, no-documentations tutorial.
 

Accname

2D-Graphics enthusiast
Reaction score
1,457
I dont know.
Walking is pretty easy and trivial.
Do you think somebody who has problems implementing a walking algorithm on his own, is not better adviced to look out for an other profession?
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,260
I'm just blogging my own projects and taking notes with me. That is all. :D
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,260
Update:

I've added obstacles and the infamous slow walking:

In a Pokémon game, when your character hits an obstacle, and you keep pressing the directional button facing the obstacle, your character will do a "slow-motion walking", while the game keeps playing the "bump" sound file.

I recreated that "slow-motion walking" when you bang with a tree.

Please test, and always, feedback is appreciated. You can also take a look at the source code, attached below. I've refactored the source code quite a lot, along with taking into account the planned workflow (here), and finally implementing them altogether.
 

Attachments

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,260
Note: If you use Mercurial, or TortoiseHg, I've also included the folder to see the entire project's changelog and whatnots.


Update again:

Fixed some rendering issues when the test area is offset upwards up too high. The same issue will occur when the character is near the very bottom of the test area.

Also, modified the artwork a little bit, and added some more inputs: You can now use WASD keys to move up and down.

The test area is now larger (taller, not wider). It reminisces the NES world scrolling, well, sort of I guess.

Source code has been updated.

=================================================================

For those interested in the source files:

I have added the option to use Generation 1 Pokémon walking or Generation 2 Pokémon walking while running the program. In Gen 1, your character isn't able to just turn around and face a direction without walking. In Gen 2, however, you can turn around on the spot without walking.

The option can be found in the InputHandler.java, where the source code is located in the "main" package. I have put a comment about the option there for your reference.
 

Attachments

camelCase

The Case of the Mysterious Camel.
Reaction score
358
Tom, gimme' till the end of the week, man. I'll test this out and whatnot. I'm still workin' on school assignments =P
 

camelCase

The Case of the Mysterious Camel.
Reaction score
358
Awesome, movement's a lot more smooth now but the input still lags on occasion =P
Maybe next is jumping down cliffs ;)
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,260
Awesome, movement's a lot more smooth now but the input still lags on occasion =P
Maybe next is jumping down cliffs ;)
The lag you're experiencing is a known Java KeyListener issue. I can't help it, no matter how strongly I wanted to do.
 

Attachments

Last edited:

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,260
I have moved to GitHub, if anyone else wanted to see the source code.

http://github.com/tommai78101/PokemonWalking

Notable fixes:
- Fixed a hidden corrupted file that causes me not able to upload a working runnable JAR file.
- Tweaked the walking algorithm, so that it doesn't cause the player to jam itself into the trees and unable to stop.

Known Issues:
- If you press the directional buttons (D-pad, WASD keys, Up/Down/Left/Right keys) very quickly, you'll spaz out and be unable to recover.
 

Attachments

Last edited:
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Sunday!
    +1
  • ToshibaNuon ToshibaNuon:
    Happy sunday!
    +2
  • The Helper The Helper:
    And its Friday!
  • The Helper The Helper:
    Happy Saturday!
    +1
  • V-SNES V-SNES:
    Happy Saturday!
  • The Helper The Helper:
    Happy Monday!
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    Happy Friday!
    +1
  • tom_mai78101 tom_mai78101:
    Starting this upcoming Thursday, I will be in Japan for 10 days.
  • tom_mai78101 tom_mai78101:
    Thursday - Friday will be my Japan arrival flight. 9 days later, on a Sunday, will be my return departure flight.
    +2
  • The Helper The Helper:
    Hope you have safe travels my friend!
    +1
  • vypur85 vypur85:
    Wow spring time in Japan is awesome. Enjoy!
  • The Helper The Helper:
    Hopefully it will be more pleasure than work
  • vypur85 vypur85:
    Recently tried out ChatGPT about WE triggering. Wow it's capable of giving a somewhat legitimate response.
  • The Helper The Helper:
    I am sure it has read all the info on the forums here
  • The Helper The Helper:
    i think triggering is just scripting and chatgpt is real good at code
  • vypur85 vypur85:
    Yeah I suppose so. It's interesting how it can explain in so much detail.
  • vypur85 vypur85:
    But yet it won't work.
  • The Helper The Helper:
    it does a bad ass job doing excel vba code it has leveled me up at my job when I deal with excel that is for sure
  • vypur85 vypur85:
    Nice! I love Excel coding as well. Has always been using Google to help me. Maybe I'll use ChatGPT next time when I need it.
  • The Helper The Helper:
    yeah whatever it puts out even if it is not perfect I can fix it and the latest version of chatgpt can create websites from pictures it will not be long until it can do that with almost all the tools
    +1
  • The Helper The Helper:
    These new Chat AI programs are going to change everything everyone better Buckle the Fuck Up!
  • The Helper The Helper:
    oh and Happy Tuesday Evening! :)
    +1

    The Helper Discord

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top