[Java] Pokémon Walking algorithm

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,663
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,099
  • walking.zip
    32.2 KB · Views: 926
Last edited:

Accname

2D-Graphics enthusiast
Reaction score
1,462
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,663
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
362
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,663
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,663
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: 543
  • walking.zip
    33.7 KB · Views: 533

Accname

2D-Graphics enthusiast
Reaction score
1,462
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,663
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,462
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,663
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,663
Take a screenshot and post it here @Tom
Sure.

agiBrIy.png
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,663
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: 466
  • walking_src_v2.zip
    60.5 KB · Views: 457

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,663
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: 519
  • walking_v3.zip
    45.5 KB · Views: 453

camelCase

The Case of the Mysterious Camel.
Reaction score
362
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
362
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,663
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: 402
Last edited:

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,663
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: 489
  • editor_debug_test.zip
    179.9 KB · Views: 475
Last edited:
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol

      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