Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: 1 2 [3] 4   Go Down

Author Topic: Pokemon Walking Engine  (Read 12268 times)

0 Members and 1 Guest are viewing this topic.
Re: Pokemon Walking Engine
« Reply #40 on: September 19, 2008, 05:26:38 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
It just looks like a lot because it is just in one file.  As I get further, I will branch off certain files to include character code and whatnot.  As I said though, some of the code is probably redundant because I just made sure it would work not that it would be efficient; the way I code also is more vertical than horizontal, and a big chunk of that code is for loading the image animations, and another chunk is just SDL drawing to the screen.  It just looks like a lot.

Oh, and it should also be noted that there is a lot of commenting in that which can later be removed.
« Last Edit: September 19, 2008, 05:29:39 pm by 4Sword »
Logged
Re: Pokemon Walking Engine
« Reply #41 on: September 19, 2008, 05:35:11 pm »
  • The devil in the mirror.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 238
You might get past the tapping=faster bug by sepparating the move function into SetMove() and DoMove(). Where SetMove = when pressing the key, and DoMove is called each frame, I'm not too sure, not used to other people's code =P
Logged
Working on my Masters Degree in Computer Science.
Hey look, Zelda Coop....later.
Proud user of C++ for 9 years, and counting!
Re: Pokemon Walking Engine
« Reply #42 on: September 19, 2008, 05:41:51 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
Yeah, originally the movement code from the tutorial I was looking at had it so pressing keys would set your velocity and then there would be code that moved you.  I remember it being smoother, but it had diagonal movement.  By setting up my code the way I did, it can't happen because you can only move in one direction from a grid space (or whenever x % 16 == 0 && y % 16 = 0, same thing really).

The SetMove and DoMove methods would probably work out better though because in upcoming code, NPCs will have movement based not on key presses.  Separating the code would just be a better use of space.

But really, lol, I put this together over the course of about a day and a half, it wasn't going to be that good.  I am just happy that I was able to get the animation to work decently, >.<.
Logged
Re: Pokemon Walking Engine
« Reply #43 on: September 19, 2008, 05:44:08 pm »
  • The devil in the mirror.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 238
Well, the reason you're getting the speedup when pressing a key, is because the move code is called each time a button is pressed AND after the event check. Sepparating them would mean it could update key's without actually doing any moving, and then move afterwards.
Logged
Working on my Masters Degree in Computer Science.
Hey look, Zelda Coop....later.
Proud user of C++ for 9 years, and counting!
Re: Pokemon Walking Engine
« Reply #44 on: September 19, 2008, 05:49:12 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
Ah, thanks.  As I am typing this out, it sounds even to me like sarcasm but I assure you it is not, but until you wrote out that first sentence of your last post, that was what I was not realizing.  I'll get to work on that then.  Realizing the shear power of C++ with at least SDL makes me wish I could have gotten through Game Maker a bit sooner though, lol. 
Logged
Re: Pokemon Walking Engine
« Reply #45 on: September 19, 2008, 05:51:53 pm »
  • The devil in the mirror.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 238
C++ is powerful, yet dangerously so =P
Logged
Working on my Masters Degree in Computer Science.
Hey look, Zelda Coop....later.
Proud user of C++ for 9 years, and counting!
Re: Pokemon Walking Engine
« Reply #46 on: September 19, 2008, 11:00:48 pm »
  • Drop down and give me 9000!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 426
Thanks for the pm, it works fine now :), sounds like you'll be getting the walk bug fixed in no time at all.

If you made one room the size of the pokemon world from blue/red in gamemaker with everything all done and tiled and all required sprites, compared to doing the same in C++ I assume the gamemaker would slow down dramatically but C++ would handle it flawlessly?
Logged
I like potato.
  • My Myspace
Re: Pokemon Walking Engine
« Reply #47 on: September 19, 2008, 11:12:01 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
Yeah, setting up a view should not be that difficult but I am not familiar yet with tiling, but I think that it is possible so that the program doesn't tile everything at one but once when you get close to the outskirts of the area.  It is odd to think about it but it kind of feels like Game Maker if Game Maker were to be crammed into "Execute Code" statements, with Game Maker's objects being classes, and having C++ do functions better (arrays  and variable types make it worth it alone).

As for speed, C++ wouldn't have all the extra bulk that Game Maker puts in with it, so it will be smaller.  I don't think that the Pokemon overworld though is one big area as there are areas off the map that crash the game and if you walk through a wall in the original, the tiling messes up and it forgets where you are. 
Logged
Re: Pokemon Walking Engine
« Reply #48 on: September 20, 2008, 04:32:58 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
Oh, and just to update, I split my movement code back into two parts and it works perfectly now with that.  Right now, I am trying to add a rock object that you can run into which prevents movement.
Logged

Mirby

Drifter
Re: Pokemon Walking Engine
« Reply #49 on: September 20, 2008, 04:41:07 pm »
  • To bomb or not to bomb...
  • *
  • Reputation: +6/-0
  • Offline Offline
  • Gender: Female
  • Posts: 4162
Make sure it makes the bump SE. Then it will be perfectly accurate!
Logged

Mirby Studios | Share & Enjoy now available! (Links above!) | Games I've Beaten
Quote from: Mamoruanime
I like-like it :D
  • Mirby Studios
Re: Pokemon Walking Engine
« Reply #50 on: September 20, 2008, 04:44:54 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
Ugh... ripping the sound effects is not so easy nor is it that necessary for any of the real code yet.  I am pretty sure that the bump sound is made when Ash is on a walking frame while his movement is being obstructed.
Logged
Re: Pokemon Walking Engine
« Reply #51 on: September 20, 2008, 04:52:54 pm »
  • Super Hero Time!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 4859
I am pretty sure that the bump sound is made when Ash is on a walking frame while his movement is being obstructed.

Pretty much. The sound only plays every stepping frame anyways. So it's like...

Step/Play - Stand - Step/Play - Stand and so on.
Logged
!@#$% I lost my entire post, god dammit.
Re: Pokemon Walking Engine
« Reply #52 on: September 23, 2008, 06:09:14 am »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
Alright, update.  I fixed the previous issue with tapping to go faster and added a Clefairy that follows Ash around in the SDL version of this project which is now located at:

http://www.zfgc.com/index.php#?action=games&sa=view&id=82
http://www.zfgc.com/index.php?action=games&sa=getdownload&id=268

Note: I have not added it yet, but when you idle for a while, the character that follows you (Clefairy) should start facing random directions.  Also, once I add collision events, so of the following stuff may get different - if you are at a corner between two walls and you are facing left with Clefairy facing left, you stop, then you do down, Clefairy's direction will then not change.  Also, in the original games there is a delay for Ash's movement when he tries to go through the following object if he is moving from a stopped position or of some other small value, I'll add this later once I work out collisions.


Logged
Re: Pokemon Walking Engine
« Reply #53 on: September 23, 2008, 06:15:39 am »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
I have to say, 4Sword; you're getting good, and I'm glad to see that SDL and C++ is working out for you.

Good luck in continuing this project, I'm cheering for your C++ version.
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: Pokemon Walking Engine
« Reply #54 on: September 23, 2008, 07:27:00 am »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
Ah, thanks.  It works out fine, but it was kind of funny how long it took me to figure out how to make it so when Clefairy was on Ash's previous grid space that its direction would change to Ash's - the ultimate cause of the problem was that I had a local variable in Clefairy that was the same name as the global variable - I can't believe I didn't see it yesterday when I knew that was exactly what to look for and yet I was unable to find it then.

Looking ahead, ledge jumping should not be that difficult to implement either even with an object that follows Ash because the object that follows Ash has its movement based on Ash's' - i.e. following object is only delayed if Ash is delayed.  Then I could have a variable for x and y offset for drawing manipulated by the distance between the current (or next grid space since ledge doesn't count as a landing space) and previous space to get the displacements.  Clefairy's image displacement could be based around its x and y and its relation to Ash's previous x and y, but meh: I haven't thought all of that out yet, should work though.

But yeah, SDL is pretty cool.
Logged
Re: Pokemon Walking Engine
« Reply #55 on: September 23, 2008, 07:45:38 am »
  • The devil in the mirror.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 238
I haven't done any direct code for having objects follow yet, but wouldn't it be simple to jsut make a ghost history of Ash's movement?, so when he moves to the next tile, the object following him mimics the movement he did to get to the previous tile.

I dunno, something like:

struct Ghost
{
int prevt;
short prevdir;
int nextt;
short nextdir;
} ;


Or something? x3
Logged
Working on my Masters Degree in Computer Science.
Hey look, Zelda Coop....later.
Proud user of C++ for 9 years, and counting!
Re: Pokemon Walking Engine
« Reply #56 on: September 23, 2008, 08:07:00 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6206
It's good to see this is being made in C++ now. And the SDL library seems to be pretty easy to use. I might try it out too.
Logged
Re: Pokemon Walking Engine
« Reply #57 on: September 23, 2008, 08:11:10 am »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
I haven't done any direct code for having objects follow yet, but wouldn't it be simple to jsut make a ghost history of Ash's movement?, so when he moves to the next tile, the object following him mimics the movement he did to get to the previous tile.

I dunno, something like:

struct Ghost
{
int prevt;
short prevdir;
int nextt;
short nextdir;
} ;


Or something? x3

The way I was thinking about it is that the following object would just follow and have its code based on positions and not action; as you go when you are not at the leader's previous position and you fix your direction when you make it there if need be.  Ash may also have to refer back to his previous position in some cases.  I think it ends up in the long run to where just basing it on positions cuts down on the number of variables, but meh, I do not know; not sure when structures would fit either in the scheme of things.

I figure I will just work until I hit an obstacle and then think it over.

It's good to see this is being made in C++ now. And the SDL library seems to be pretty easy to use. I might try it out too.

Yeah, I have a C++ assignment due for class at 11:59 PM CST tonight which I should have spent my time on, lol, but compared to all this nonsense, it should be easy enough - just a program with functions and print-outs and I will probably just work on it in class and get it done there. 

The SDL library is pretty easy to use, but I really owe Lazy Foo' Productions and their tutorials for helping me get the concepts.  Once I learned how it was different from what I was doing in Game Maker and how it was similar, crossing over wasn't that difficult.

Logged
Re: Pokemon Walking Engine
« Reply #58 on: September 23, 2008, 08:14:12 am »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
Told you those tutorials would help ;)
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: Pokemon Walking Engine
« Reply #59 on: September 23, 2008, 09:08:22 am »
  • The devil in the mirror.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 238
Positions? So you keep a vector of variables with previous positions? like
int oldpos[16]; ?

Anyway, If I don't remember wrong, The following character should always copy your last movement. If you move to the Left, and the move down, the one following you should move left, and then move down the next time. I can't see how that is easily done without keeping some kind of history of Ash's movement.
Logged
Working on my Masters Degree in Computer Science.
Hey look, Zelda Coop....later.
Proud user of C++ for 9 years, and counting!
Pages: 1 2 [3] 4   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.194 seconds with 75 queries.