The Daily Click ::. Forums ::. Klik Coding Help ::. Need some tips on coding items for a platformer
 

Post Reply  Post Oekaki 
 

Posted By Message

derek calavera



Registered
  01/04/2009
Points
  4
29th April, 2009 at 11:44:30 -

I am a flash designer, but have been toying with MMF2 and reading the tutorials for the past few months and I have cobbled together a very simple platform engine. The gameplay for my as-yet-unfinished game will be similar to Kirby.

There are 3 issues I need to work out before I can proceed further, and I am seeking your help before I begin to code these aspects so I can come up with elegant solutions.

1. The player should gradually increase in size over the course of the game. Should I draw sprites in various sizes to attach to the player's placeholder? Should I use the scale function and a counter (I have tried this and it looks a bit slopppy, but will work with different animations such as walking, jumping etc without having to redraw everything for a 1 pixel size increase). When the player steps up in size, I would like to avoid him being stuck in the ground or the wall he is standing next to (I need tips on keeping my detectors from bulging into the background objects). Should I use some trickery with the landscape (making it appear smaller) to increase the effect - like the Mario level where the bricks and koopas are giant-sized but mario is normal?

2. The player will encounter different hats he can put on and take off at will. When he reaches a certain size, if the hat is too small it will pop off his head and he can no longer put on such a small hat. Using a counter called player_size, I can produce this effect (if player_size > n, run loop "remove hat", set hat value to unwearable). In order to stick the hat on I have tried using flags\fastloops (if player is +/- 10 pixels away from hat and presses Space, set hat flag 0 on, always: if hat flag 0 is on attach to players hotspot, if hat flag 0 is on and presses space, set flag off) but this gave me mixed results and sometimes broke itself. This action is sort of like picking up different guns\dropping them, I would like any advice on a simple way to code this. I would like to be able to hide the players head if he puts on a hat and show it again when he takes it off, but I have been unable to code this - tried using separate head\body sprites and it wasnt pretty.

3. The player will encounter badges\flowers\pins etc, which he can pick up and place on the hat he is currently wearing. They will be permanently attached to the hat. Ideally these actives would remain unique and not become part of the hat sprite. I have tried putting contact points (invisible actives) that are locked n x and n y pixels from the hats hotspot, and then attaching found objects to these contact points, but it seems like a messy way of going about this. The badges\etc will need to have some code of their own (for generating particles or touching enemies or whatever).

I have been doing pixel art and scripting for years, but I am new to MMF2. Thank you so much for your help.






 
n/a

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
29th April, 2009 at 13:04:19 -

1. Depending on how the characters features work, could you not have one body drawn at its maximum size, and then shrunk down in the game rather that enlarging a smaller sprite? That would certainly make it look better. And could the features (eyes, mouth etc) be drawn as a seperate active that isn't resized?

2. Give each hat a size value. If player size>hatsize; drop hat. If player isn't wearing a hat and player collides with hat and player size<hatsize; pick up hat.

3. Use the hotspot instead. If player collides with pin and player isn't currently holding a pin; set the pins flag on. Flag on; set position to hats hot spot.

Sorry if they seem kind of vague.

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
29th April, 2009 at 13:10:14 -

I'd advise against using the in-game resizing because you're right it does look sloppy. Maybe you could get away with it for something like a bullet or explosion but for a player's sprite it wouldn't be a good idea. If you have the ability to draw the sprites yourself in different sizes that would look way better, even though it'd probably take a lot more time.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
29th April, 2009 at 14:36:03 -

D'oh I mean't use the Actionspot, not the hotspot for point 3.

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

~Matt Esch~

Stone Goose

Registered
  30/12/2006
Points
  870

VIP Member
2nd May, 2009 at 09:57:46 -

I would suggest vector or 3d based graphics if you're looking to resize smoothly. If you are looking to use sprites then I think it would be better to use just 3 or 4 sizes in larger steps, and although it doesn't sound as cool it would probably fit well with the graphic style if you made the sprite flash or something before sizing in big steps. (Think Mario).

As far as detectors are concerned, I think I would just let my detectors bulge into the background, but move them 1 pixel at a time. Move 1 pixel then call a fastloop to reposition the character based on detectors, I think it would work nicely.

If you want to code anything where things move together then make sure you do exactly that, move everything at the same time. If I was coding your hats I would use an active object that's always in the hat position. At the start of the level arrange it in the correct position (in code) relative to the player. I don't normally reposition anything relative to the player after that. You don't have to set the position of detectors or related objects at any other time (other than if it's a purposeful effect, but I tend to just change the animation rather than positions of things) relative to the player, you set their positions relative to their own positions. So imagine this

> I place the player on the level where I want him to start
> In code -
At the start of the level position left detector x position to x player - 16
position right detector x position to x player + 16
position hat x position to x position player
position hat y position to y player - 16
...
etc

And then any time I cause movement to the player such as moving left or right or jumping I make sure that I move all of the relative objects. You might be able to add these objects all to the same group (use a qualifier) so you don't have to keep copying the code and you can add more relative objects later.

Repeat while right joystick: player x = player x + 1
player right detector = player right detector + 1
.... etc

And then call a fastloop to detect any collisions that may have occured in the movement.

If you use a qualifier instead of changing each object's position then you can code something like
group player x = group player x + 1,
and that will move everything in the player group. So for your third question, you could create some items, put them in the player group, and then wham you have relative items.

I would write an example but I don't have MMF installed at the moment (currently sampling Windows 7 inbetween a Windows XP reinstall). Hope this helps though.

 
http://create-games.com/project.asp?id=1875 Image


derek calavera



Registered
  01/04/2009
Points
  4
3rd May, 2009 at 00:06:47 -

I typed out a huge post and it seems to have dissapeared. Thank you all for your tips, I have tried to implement some of your ideas and have created a small mockup.
Dr James:
excellent ideas for the hats and badges, however how can I make it so that more than 1 badge can be added to a hat. Do i need to code separate offsets from the action spot for each badge (as in badge1 attaches to action point, badge2, attaches to actionpoint +5x+5y, badge3 attaches to +10x-10y, etc?) should i make a value to count the number of badges currently held in order to calculate this???

Del: I actually kind of like the look of an overblown up sprite (ala mode7), it has a certain retro charm. But I feel where youre coming from on vector graphics (flash does wonders with them). I am able to draw multiple sizes of the character, or draw an extra large version and srhink him down (as the dr suggested)

Matt: i think i understand the idea behind your code but i am a bit confused as to how MMF handles groups\qualifiers. I am also testing the beta of windows 7 x64 and MMF2 runs perfectly well with no workarounds, if you were wondering about installing it but didnt feel like trying to get it to work on vista\7.

I have uploaded a mockup of my game in MFA here http://www.megaupload.com/?d=GWU1HVV0

for your criticism and correction.


Thank you so much for your extremely helpful and rapid responses.



 
n/a

~Matt Esch~

Stone Goose

Registered
  30/12/2006
Points
  870

VIP Member
3rd May, 2009 at 00:52:57 -

A very quick example of what I mean

http://www.mattesch.info/click/movetogether.mfa

I just have to move 1 object (the player qualifier) and all objects that are part of the player group move by the same amount, so we retain relative positioning.

Edit:

I have created a version with resizing too:

http://www.mattesch.info/click/resize.mfa

Controls:

Move - up/down/left/right arrows
Grow - space bar
Shrink - ctrl

For some reason the Y Top and Y Bottom (these are supposed to be the Y position of the top and bottom of the active) is incorrect after resizing, it reports the y bottom as if it was not scaled. I want to put the the hat at the Y Top of the player, minus the height of the hat

Y Top( "Player" )-(Y Bottom( "Hat" )-Y Top( "Hat" ))

See that the height of the hat is retrieved from subtracting the y top of the hat from the y bottom of the hat. But seeing as this is reported as the original size I have had to multiply by the Y Scale to get the resized size of the hat.

Y Top( "Player" )-(Y Bottom( "Hat" )-Y Top( "Hat" ))*YScale( "Hat" )

I will submit this to clickteam and see if they think it's a bug or not.

Edited by ~Matt Esch~

 
http://create-games.com/project.asp?id=1875 Image


derek calavera



Registered
  01/04/2009
Points
  4
5th May, 2009 at 17:33:53 -

Thank you very much Matt, your second example was very helpful. That is a strange bug, maybe it is testing the y-bottom coordinate right before resizing? I still do not understand how using the qualifier would allow for the hat to be switched to a different hat during the frame. If I move all "player object" qualified actives, while the hat attached to the players head moves wont the next hat that is just lying around move as well? Can Qualifiers be turned on and off like flags?

 
n/a

~Matt Esch~

Stone Goose

Registered
  30/12/2006
Points
  870

VIP Member
5th May, 2009 at 18:06:34 -

For simplicity I would suggest that your hat is just 1 active object with different animations for each hat. No you can't just turn off qualifiers just like that, or add a qualifier to an object at runtime (we would like this but as far as I'm aware this isn't possible yet) but you can just add an additional flag to your code so you only move player objects with flag 1 on or something. I suggested using a qualifier so that you may add an arbitrary number of items to the hat. Say that square active in the example is the hat, you would give that multiple animations, one for each hat. I think you could actually use separate frames, set the animation speed to 0 and then change which frame is being displayed. The hats ingame won't be the same thing, they will be different hats. When a hat pops off because it's too small, you make the square active invisible, and create a hat object to simulate the popping off.

 
http://create-games.com/project.asp?id=1875 Image

   

Post Reply



 



Advertisement

Worth A Click