Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 2863 times)
0 Members and 1 Guest are viewing this topic.
Offline JonnyGingerKid

Senior Newbie


Exp: 1 year



« 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
« 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
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
//Basic class stuff
public void render(Graphics g) {
     g.drawImage(sprite, x, y, null);
}

public void tick() {
     x+=velX;
     y+=velY;
}
//Other basic class stuff


Gun class
1  
2  
3  
4  
5  
//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
https://www.youtube.com/user/InidDevo
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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (22 views)
2014-09-19 03:14:18

Dwinin (35 views)
2014-09-12 09:08:26

Norakomi (62 views)
2014-09-10 13:57:51

TehJavaDev (88 views)
2014-09-10 06:39:09

Tekkerue (43 views)
2014-09-09 02:24:56

mitcheeb (65 views)
2014-09-08 06:06:29

BurntPizza (47 views)
2014-09-07 01:13:42

Longarmx (35 views)
2014-09-07 01:12:14

Longarmx (40 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!