Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (739)
Games in Android Showcase (224)
games submitted by our members
Games in WIP (820)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  RPG armor/weapon system?  (Read 9289 times)
0 Members and 1 Guest are viewing this topic.
Offline JonnyGingerKid

Junior Devvie

Exp: 3 years

« Posted 2014-03-08 19:07:32 »

So I'm making a 2D top down RPG with LWJGL and I wanted the player to be able to carry some kind of armor as well as a weapon, and have those items affect what the player sprite looks like. But I ran into a problem. If I have the character sprite, that has lets say 8 images (2 for walking left, 2 for walk right, 2 for walking up, and 2 for walking down), do I have to create 8 more for every possible combination of weapons and armor? How is THAT efficient? I know their must be another way....
Offline Troubleshoots

JGO Knight

Medals: 36
Exp: 7-9 months

Damn maths.

« Reply #1 - Posted 2014-03-08 19:12:24 »

It's simple. If you have lets say 10 different hats, you could create 10 head sprites facing forward, 10 facing left, 10 facing right and 10 facing backwards. You could do the same for the body, legs, feet and hands.

Why are all OpenGL tutorials written in Brainf**k?
Offline Gibbo3771

JGO Kernel

Medals: 128
Projects: 5
Exp: 1 year

Currently inactive on forums :(

« Reply #2 - Posted 2014-03-08 19:12:43 »

Modular sprites.

Split your player sprites into seperate parts, Legs, Torso, Arms, Head.

Afaik this is the only way.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jacob Pickens
« Reply #3 - Posted 2014-03-08 19:13:12 »

hmm well in my game I have a player who can obtain different fire arms. I just draw that new fire arm's sprite on top of the player. So maybe you could do that with the ammo. You could go about it like this:

Player Class
//Basic class stuff
public void render(Graphics g) {
     g.drawImage(sprite, x, y, null);

public void tick() {
//Other basic class stuff

Gun class
//Class Stuff
public void render(Graphics g) {
     g.drawImage(sprite, Player.x - 16, Player.y + 16, null); //The subtraction and addition would be positioning on the player
//Other class stuff

Hope this helps!

Offline VIrtueeL
« Reply #4 - Posted 2014-03-08 19:47:08 »

all you need is 4 images then just rotate them to your needs do same with weapons / hats / armor

i do devlogs and i do tutorials check em out
Offline lcass
« Reply #5 - Posted 2014-03-08 19:54:22 »

rotation and drawing it ontop is probably the easiest way. you can do 8 different sprites however you will have memory issues if you have thousands of items.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Ecumene (49 views)
2017-09-30 02:57:34

theagentd (74 views)
2017-09-26 18:23:31

cybrmynd (183 views)
2017-08-02 12:28:51

cybrmynd (181 views)
2017-08-02 12:19:43

cybrmynd (188 views)
2017-08-02 12:18:09

Sralse (195 views)
2017-07-25 17:13:48

Archive (745 views)
2017-04-27 17:45:51

buddyBro (878 views)
2017-04-05 03:38:00

CopyableCougar4 (1428 views)
2017-03-24 15:39:42

theagentd (1317 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!