[Java] Pokémon Walking algorithm

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,828
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

  • walking_src.zip
    110.9 KB · Views: 1,140
  • walking.zip
    32.2 KB · Views: 965
Last edited:
Yeah. It really feels like pokemon. But i wouldnt say that the way the movement in pokemon felt like was something positive.
 
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.
 
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.
 
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.
 
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

  • walking_src.zip
    111.7 KB · Views: 577
  • walking.zip
    33.7 KB · Views: 569
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.
 
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.
 
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?
 
I'm just blogging my own projects and taking notes with me. That is all. :D
 
Take a screenshot and post it here @Tom
Sure.

agiBrIy.png
 
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

  • walking_v2.zip
    45 KB · Views: 493
  • walking_src_v2.zip
    60.5 KB · Views: 484
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

  • walking_src_v3.zip
    357.4 KB · Views: 548
  • walking_v3.zip
    45.5 KB · Views: 480
Tom, gimme' till the end of the week, man. I'll test this out and whatnot. I'm still workin' on school assignments =P
 
Awesome, movement's a lot more smooth now but the input still lags on occasion =P
Maybe next is jumping down cliffs ;)
 
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

  • editor_v5_mac_test.zip
    236.5 KB · Views: 432
Last edited:
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

  • walking_v4.zip
    49.1 KB · Views: 515
  • editor_debug_test.zip
    179.9 KB · Views: 503
Last edited:
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    I would be there for days, even with my camera set up slides can take a long time, and if they want perfect captures I really need to use my scanners that are professionally made for that. My camera rig works well for what it is, but for enlargements and things it's not as good.
  • Varine Varine:
    I've only had a couple clients with that so far, though. I don't have a website or anything yet though.
  • Varine Varine:
    Console repair can be worthwhile, but it's also not a thing I can do at scale in my house. I just don't have room for the equipment. I need an office that I can segregate out for archival and then electronic restoration.
  • Varine Varine:
    But in order for that to be real, I need more time, and for more time I need to work less, and to work less I need a different job, and for a different job I need more money to fall back on so that I can make enough to just pay like, rent and utilities and use my savings to find these projects
    +1
  • Varine Varine:
    Another couple years. I just need to take it slow and it'll get there.
  • jonas jonas:
    any chance to get that stolen money back?
  • jonas jonas:
    Maybe you can do console repair just as a side thing, especially if there's so much competition business might be slow. Or do you need a lot of special equipment for that?
  • jonas jonas:
    I recently bought a used sauna and the preowner told me some component is broken, I took a look and it was just a burnt fuse, really cheap to fix. I was real proud of my self since I usually have two left hands for this kinda stuff :p
  • tom_mai78101 tom_mai78101:
    I am still playing Shapez 2. What an awful thing to happen, Varine, and hopefully everything has been sorted out soon. Always use multi-factor authentication whenever you have the opportunity to do so.
    +1
  • Varine Varine:
    I think all of the money is accounted for now, and all the cards have been changed out, so I think for the most part it's taken care of now. Just need to go through and make sure all of my accounts are secured again, it's just time consuming.
  • Varine Varine:
    And yeah everything has 2 factor turned on now, or at least everything I can think of at the moment.
  • Varine Varine:
    The consoles don't need too much equipment that I don't already have. I would like to get a reflow oven, but I don't really want to buy one so I'm thinking about modifying a toaster oven I have to make something that will work for what I'm doing.
  • Varine Varine:
    I have the soldering irons and reflow and all that, but without an oven it's kind of hard to build mod chips and things like that. I made a handful of them with a hot air station, but it's a pain.
  • Varine Varine:
    The only thing I'm not really set up for is BGA rework. I've done it before a little bit, but not reliably, and that equipment is wildly expensive. You need X-rays and shit.
  • Varine Varine:
    I also have a couple 3D printers. I'm not super good with those and need to get an enclosure built, but they'll be useful for some aesthetic mods I've been thinking about. At least I can use them to do designs and then just have someone else print out the parts for me once I know they work.
  • Varine Varine:
    I also use them to make adapters for all my camera shit, but that's also an on the side thing for now. Lens adapters get really expensive.
  • Varine Varine:
    I've been trying to do some little art pieces as well, but I'm not much an engineer so they haven't gone great. I got some new things showing up to try and play with
  • Varine Varine:
    I want to build this tesserect kind of thing with mirrors, and I've been trying to make this like black hole diorama. In my head it looks really cool, but I kind of thought I could form polarizing lenses into a sphere but I tend to just destroy them every time I try.
  • Varine Varine:
    So I got a new idea, but I'm not sure how to make it work like I want without being able to get a polarizer curved. I think they are made out of PVA typically, and I thought I could just heat it up a little bit to soften the film, but that clearly isn't working. So I'm going to try a few other things, I'm thinking if I put a mirror film over the polarizing film I might get something cool. I have some polarized LED's as well, and I think if I make a central light source I can use the mirrors combined with the polarizers to make that central light APPEAR black. I have next week off so I'm going to spend some time trying to figure it out
  • Varine Varine:
    The tesserect works, at least. I just need to figure out how to be able to assemble it, but I think I have a pretty good idea of how to go about it. Or at least a prototype of it. I'll post some pictures next week
  • jonas jonas:
    That last bit sounds like the last entry in a scientist's journal in a destroyed research facility in a post-apocalyptic video game
  • Varine Varine:
    lol it's not that exciting
  • Varine Varine:
    Shiny tho
  • Varine Varine:
    Basically it's a cube with a two way mirror on the inside, and then a smaller cube suspended in that with a mirrors on the outside of it. Kind of like those infinity pictures where they use two mirrors to go forever. Only it's twelve mirrors
  • Varine Varine:
    And the tiniest LED strip I could find

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top