Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (537)
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  
  Rendering Health-System like Zelda or MineCraft?  (Read 662 times)
0 Members and 1 Guest are viewing this topic.
Offline roseslayer

Junior Member


Medals: 1



« Posted 2013-03-29 13:16:16 »

Hello there,

Currently I'm working on a small RPG game, but in a RPG game you need health. So I started to begin with coding the health system. The only part that´s still missing is the part of rendering them. The part that I already finished is that you have total 12 hp (in half heart so 6 hp total) and the damage system.

Idea
My idea was to make "half" hearts, this aren't really half hearts but just the same heart image with other color.
If you have as example 7 hp (3,5 hearts total) But how can you code the rendering of this idea?

I don't want the full code, give me some hints/tips how I can do this. I still need too learn alot.
-RoseSlayer

Fundamentum W.I.P.
Offline Cero
« Reply #1 - Posted 2013-03-29 13:22:21 »

eeeh sure, well its kinda different if you use opengl directly or a lib or java2d...

Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #2 - Posted 2013-03-29 13:22:45 »

I would just make textures for all the hearts. That's just my lazy side talking though, I'm sure there's a way to actually do it with code. It would probably be much harder than just texturing hearts for every possibility though. Maybe someone else has a suggestion?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline roseslayer

Junior Member


Medals: 1



« Reply #3 - Posted 2013-03-29 13:24:51 »

@opiop65,
I want to save as much space in my spritesheet as possible, so not the greatest option.

@Cero,
I'm using eclipse with java jdk1.7_0 (maybe jdk1.6_0) only so nothing else then that.

-RoseSlayer

Fundamentum W.I.P.
Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #4 - Posted 2013-03-29 13:27:40 »

It's really easy:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
int numberOfFilledHearts = hp / 2; // <- This HAS to be an Integer!
boolean extraHalfHeart = hp % 2 == 1;

int i = 0;
for (; i < numberOfFilledHearts; i++) {
    drawFilledHeart(x + i*heartWidth, y);
}
if (extraHalfheart)
    drawHalfHeart(x + i*heartWidth, y);
}


That's it.
(btw, the % operator is modulo <edit>modulo = remainder of division. So i % 2 == 0 for example checks, whether the number is a round number</edit>)

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline roseslayer

Junior Member


Medals: 1



« Reply #5 - Posted 2013-03-29 13:29:56 »

@matheus23,

I will try the code out, but already thanks for helping me out!

-RoseSlayer

Fundamentum W.I.P.
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.

CogWheelz (16 views)
2014-08-01 22:53:16

CogWheelz (15 views)
2014-08-01 22:51:43

CopyableCougar4 (18 views)
2014-08-01 19:37:19

CogWheelz (19 views)
2014-07-30 21:08:39

Riven (27 views)
2014-07-29 18:09:19

Riven (16 views)
2014-07-29 18:08:52

Dwinin (14 views)
2014-07-29 10:59:34

E.R. Fleming (42 views)
2014-07-29 03:07:13

E.R. Fleming (13 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36
Resources for WIP games
by CogWheelz
2014-08-01 18:20:17

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

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

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

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

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22
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!