Jump to content

  • Log In with Google      Sign In   
  • Create Account

how to handle armor change in 2D RPG


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 cebugdev   Members   -  Reputation: 318

Like
0Likes
Like

Posted 05 March 2014 - 05:18 PM

Hi,

This is not my project but a friend of mine is asking how armor change such that of DIablo 2 or any other 2D RPG were handled in the game?
by armor change i meant, say for example you have a basic character and the character found a helm, an armor and a pair of boots.

how would this reflect to the visual sprite?

 

Does it need different sprites for different armor for all characters? how bout armor combinations like armor on its feet and upper torso plus helm?

I have idea on how to do this in 3D since 3D objects can be just attached to the mesh, but i have no idea on how this works in 2D.

 

Any tips will do,

 

THanks,

 



Sponsor:

#2 ferrous   Members   -  Reputation: 2021

Like
0Likes
Like

Posted 05 March 2014 - 06:00 PM

A flat 2d game can get away with having a skeleton of sorts, and just drawing the piece of armor onto the person at the skeleton spot, or even not a skeleton but just marking each frame of animation, eg the helmet should be centered at 0,0 on frame 1 of the walk animation, 5,0 at frame 2, then you would just draw the default person, then draw the helmet after that, on top of the person.  (or if the helmet completely replaced the person's head, just draw the pieces.)

 

An isometric game like diablo..ugh, I don't know any good shortcuts, I think you'll be stuck needing to have the different pieces each depicted and animated from the basic angles.  (for example, arms with no armor swinging a weapon from North, south, east, west, arms with light armor and NSEW and arms with heavy armor NSEW, etc.)  On simple color changes, you don't need to do that, but yeah...I believe thats why early diablo basically had only a few armor types that actually changed your look graphically.



#3 Ravyne   GDNet+   -  Reputation: 7477

Like
0Likes
Like

Posted 05 March 2014 - 08:43 PM

The basic idea is that you can draw the equiped character in a series of steps. Conceptually, lets start with three imagined drawings: One of the character with base equipment, one of the character wearing upgraded boots, and one of the character wearing an upgraded helmet. The latter two are drawn over the first so that the helmet and boots line up correctly, then everything in those images that are not boots or helmet is wiped away. Now, from those three images you can draw a player who is wearing the base equipment only, is wearing the boots, is wearing the helmet, or is wearing both the boots and the helmet -- four combinations of equipment from three images. This savings might not seem like much now, but as there are more categories of equipment (helmets, boots, etc) and more kinds of equipment in each category (leather boots, steel boots, etc), the savings are compound. Specifically you will achieve number_of(helmets) * number_of(boots) * number_of(...) unique outcomes from just number_of(helmets) + number_of(boots) + number_of(...) input images. For example, with 5 kinds of 3 categories of equipment, you get 125 unique combinations from just 15 original pieces of art.

 

You do this for each frame of every animation, for each piece of equipment. With that, you can build up every animation with any combination of equipment that the player could possibly equip. Doing this by hand is very time consuming of course, but Diablo, even though it was 2D is not hand-drawn. In Diablo, all the sprites are just snapshots of a 3D model from an art program. Because of this, they were able to create the base animations and then render them all with each piece of equipment (equipment was also a 3D model in the art program).

 

Once you have all of these images, you can cut out or compress the unused portions of the image. and you also have to generate the draw order so that the players cape covers his chest-plate when he faces away from the camera, but is behind his chest-plate when he faces towards the camera. But those are just details of the basic principle.

 

All of that said, its almost notoriously-difficult to create overlapping isometric-view scenes with a lot of complexity just by using z-ordered 2D images. Because of this, many isometric games of today are, in whole or in part, actually rendered in 3D complete with z-buffer. Even Diablo does this to some extent, its just that they did it offline. Some are hybrid systems that pre-render the character wearing a particular collection of equipment, saving the images as 2D sprites, and then drawing those when in-game (usually, this is done when there are a lot of characters, or when running on low-powered platforms). The general term for this technique is 'imposter', its also used in full 3D games to draw things that are very far away. Partial or fully-3D systems also make advanced lighting and other effects more straight-forward, which is another reason those systems are more popular today than those based on 2D sprites.


Edited by Ravyne, 05 March 2014 - 08:54 PM.


#4 ngoaho91   Members   -  Reputation: 253

Like
0Likes
Like

Posted 06 March 2014 - 02:11 AM

1. character are built of many parts, you can name it, head, body(body = body + leg + foot), left hand, right hand, left weapon, right weapon.

2. you must have a list of character state, it's about 40 state as i remember, to handle such many action like diablo.

here are example:

- idle, every kind of weapon have same form if idle

- walk, no weapon

- walk, 2-handed weapon(lance, staff...)

- walk, 1-handed weapon(sword, blade, ...)

- walk, double weapon(2 sword, 2 blade at once, difference to 2-handed)

- walk, bow weapon

- run, no weapon

- run, 2-handed weapon

- run, 1-handed weapon

- run, double weapon

- run, bow weapon

.... so on, many state

 

each state must have difference animation, assume that a state have 40 animation, and a character formed from 6part. then we cost 40x6=240sprite to build a character. the number of sprite grow very fast as variation of equipment grow.

you must find a way to manage that huge number of sprite, dont load every sprite at once

and you know that kind of system needs many sprite, so never use HD assests. it's cost 4MB of disk space, after optimized, to store a helmet. you know? helmet are small, 1 frame 6x6 pixel average.

 

3. when you turn character, move up -> move left... of course you must change the animation, but it's not only thing you must do.

you must re-arrange the parts. when character move up, the order of render are -> weapon < hand < head < body. so the weapon and hand would be hide under body. but when character move down, the order reversed. basically, you must have a table to represent the order when character turning.

- up -> 1, 2, 3, 4

- down -> 4,3,2,1

- left .....

- right ....

 

that's all my experience, nothing hard, but it's complex, and if you haste(like me), you will get a mess instead of a awesome game.

4. here is mine


Edited by ngoaho91, 06 March 2014 - 02:20 AM.


#5 arka80   Members   -  Reputation: 937

Like
0Likes
Like

Posted 06 March 2014 - 03:39 AM

I'm working on something similar (2d isometric rpg, but with very simple pixel art) and planned to have a naked version of characters and various pieces of stuffs like armors and weapons to draw after the base sprite. I hope it works, also because it's not likely for a one man (or even for a small team) to produce all that amount of graphics.



#6 Poigahn   Crossbones+   -  Reputation: 519

Like
0Likes
Like

Posted 06 March 2014 - 05:46 AM

The Above Comments sound a little Complicate.  Although have not done this recently I have done The Sprites and added Different Clothing at run-time.


A flat 2d game can get away with having a skeleton of sorts, and just drawing the piece of armor onto the person at the skeleton spot, or even not a skeleton but just marking each frame of animation, eg the helmet should be centered at 0,0 on frame 1 of the walk animation, 5,0 at frame 2, then you would just draw the default person, then draw the helmet after that, on top of the person. (or if the helmet completely replaced the person's head, just draw the pieces.)

This is very close to what I did.  Here is where I differred and I hope I explain this correctly.

  • At Run-time I created a Blank Sprite Sheet with No Images for each Player Charactor (PC)
  • Next I Copied The Base Charactor Images ( Sprites ) on the Blank PC Sprite Sheet. Now I have a set of Sprites for each PC
  • Now I Selected What Clothing Options I Wanted Then overlayed those sprites onto The PC Sprite Sheets
  • I Continued This until my PC was ready to go adventuring.

Of Course each clothing / Armor / Weapon Sprite Sheet had to have the Same Animations as the Charactor Sprite.  I Saved the new Sprite Sheet with the Charactor's as the file name and would load that sprite sheet at run-time to use as my animations.  Thus controlling only 1 set of sprites for each charactor during the game.


Your Brain contains the Best Program Ever Written : Manage Your Data Wisely !!





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS