Sign in to follow this  
m_waddams

Graphics for my loderunner remake

Recommended Posts

m_waddams    274
Hi,

To start learning java game programming I remade the original Lode Runner.
I probably need to change the graphics. How do I change the color of a texture
once it is already loaded? Can I set alpha blending of any texture, or must I
create it with an alpha layer? I would like my highscore screen to overlay (alpha)
the playing screen, how?

Thanks.


[url="http://java-expert.nl/games/test/loderunner.zip"]Download Lode Runner[/url]


Animated GIF of the original, my version is a little more smooth :)
[img]http://www.c64-wiki.com/images/a/a5/Loderunner_Animation.GIF[/img]

Share this post


Link to post
Share on other sites
ryan20fun    2635
it would proberbly be a good idea to tell us:
what engine if any
are you esing DirectX / OpenGL etc

but there should be some option to tint a sprite / texture when you draw it (well in DirectX atleast)

:) :) :)

--edit---
ah, just rememberd, i used to play this on the old TV Game Set.

Share this post


Link to post
Share on other sites
m_waddams    274
[quote name='ryan20fun' timestamp='1306317290' post='4815516']
what language you are using
[/quote]Java

[quote]
what engine if any
[/quote]No engine, but lwjgl for the OpenGL binding.

[quote]
but there should be some option to tint a sprite / texture when you draw it (well in DirectX atleast)
[/quote]I tried some glColor calls, but they update all textures, not just the one I'm drawing...

[quote]
ah, just rememberd, i used to play this on the old TV Game Set.
[/quote]I played this on just about every system possible :) Since my version is Java it should play on almost anything.

Share this post


Link to post
Share on other sites
jyk    2094
[quote]I tried some glColor calls, but they update all textures, not just the one I'm drawing...[/quote]
Assuming you're not using color arrays, a call to glColor() should determine the base color for all fragments rendered subsequently. So, for example, you could just call glColor() before rendering each renderable object (sprite, text, etc.) in order to specify the color, e.g.:

[code]glColor(...);
renderLevel();
glColor(....);
renderPlayer();
// Etc.[/code]
Note that calls to glColor() don't affect the textures directly; rather, calling glColor() simply specifies what color will be used when rendering.

Share this post


Link to post
Share on other sites
[quote name='jyk' timestamp='1306344463' post='4815666']
[quote]I tried some glColor calls, but they update all textures, not just the one I'm drawing...[/quote]
Assuming you're not using color arrays, a call to glColor() should determine the base color for all fragments rendered subsequently. So, for example, you could just call glColor() before rendering each renderable object (sprite, text, etc.) in order to specify the color, e.g.:

[code]glColor(...);
renderLevel();
glColor(....);
renderPlayer();
// Etc.[/code]
Note that calls to glColor() don't affect the textures directly; rather, calling glColor() simply specifies what color will be used when rendering.
[/quote]

To further add to this, what jyk means is that if you call glColorf() and set it to red, every single texture you draw afterward will be red, until you change the color again. If you set it to full white (1.0f, 1.0f, 1.0f) then the textures will be drawn normally. Also, you can use glColor() to do alpha blending also. The fourth parameter of glColor is the alpha transparency.

Some examples:
[b]glColor(1.0f, 0.0f, 0.5f)[/b] - This is full red, no green, and half blue. Completely not-transparent, unless the image itself has transparency.

[b]glColor(0.0f, 0.5f, 0.0f)[/b] - This is no red, half green, and no blue. Completely not-transparent, unless the image itself has transparency.

[b]glColor(0.0f, 0.0f, 0.0f)[/b] - This is no red, no green, and no blue. Completely not-transparent, unless the image itself has transparency.

[b]glColor(1.0f, 1.0f, 1.0f)[/b] - This is full red, full green, and full blue - which is normal. This is completely not-transparent, unless the image itself has transparency.

[b]glColor(1.0f, 1.0f, 1.0f, [color="#ff0000"]0.5f[/color])[/b] - This is full red, full green, and full blue - same as before. Except, this one also is halfway transparent.

Think of it like this: Each pixel of your image is multiplied by the red, green, blue, and alpha of the last glColor() call. glColor() is 1.0, 1.0, 1.0, and 1.0 by default.
A call to glColor is permanent, until the next time you call it (Most of OpenGL functions work this way).
If you call glColor and only give it 3 parameters, the 4th parameter (the alpha) is automatically set to 1.0.

Consider this:
Your image's pixel: [b]Color([color="#a0522d"]123[/color], [color="#a0522d"]75[/color], [color="#a0522d"]30[/color], [color="#a0522d"]200[/color])[/b]
The last glColor call: [b]Color([color="#4169e1"]1.0[/color], [color="#4169e1"]0.5[/color], [color="#4169e1"]0.75[/color], [color="#4169e1"]0.5[/color])[/b]
Multiply the two together, [b]Color(([/b][b][color="#a0522d"]123 [/color]* [/b][b][color="#4169e1"]1.0[/color]), ([/b][b][color="#a0522d"]75 [/color]* [/b][b][color="#4169e1"]0.5[/color]), ([/b][b][color="#a0522d"]30 [/color]* [/b][b][color="#4169e1"]0.75[/color]), ([/b][b][color="#a0522d"]200 [/color]*[/b][b] [color="#4169e1"]0.5[/color]))[/b]

The result: [b]Color([color="#9932cc"]123, 37, 22, 100[/color])[/b]
(Excluding things like OpenGL fog, lighting, shadowing, anti-aliasing, and everything else)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this