Graphics for my loderunner remake

Started by
4 comments, last by m_waddams 12 years, 11 months ago
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.


Download Lode Runner


Animated GIF of the original, my version is a little more smooth :)
Loderunner_Animation.GIF
Advertisement
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.

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.


what language you are using
Java


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


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...


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.
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.:

glColor(...);
renderLevel();
glColor(....);
renderPlayer();
// Etc.

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

I tried some glColor calls, but they update all textures, not just the one I'm drawing...

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.:

glColor(...);
renderLevel();
glColor(....);
renderPlayer();
// Etc.

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:
glColor(1.0f, 0.0f, 0.5f) - This is full red, no green, and half blue. Completely not-transparent, unless the image itself has transparency.

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

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

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

glColor(1.0f, 1.0f, 1.0f, [color="#ff0000"]0.5f) - 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: Color([color="#a0522d"]123, [color="#a0522d"]75, [color="#a0522d"]30, [color="#a0522d"]200)
The last glColor call: Color([color="#4169e1"]1.0, [color="#4169e1"]0.5, [color="#4169e1"]0.75, [color="#4169e1"]0.5)
Multiply the two together, Color(([color="#a0522d"]123 * [color="#4169e1"]1.0), ([color="#a0522d"]75 * [color="#4169e1"]0.5), ([color="#a0522d"]30 * [color="#4169e1"]0.75), ([color="#a0522d"]200 * [color="#4169e1"]0.5))

The result: Color([color="#9932cc"]123, 37, 22, 100)
(Excluding things like OpenGL fog, lighting, shadowing, anti-aliasing, and everything else)
Thanks a lot, I'm going to try this as soon as I get home. Should be able to pimp it a bit now :)

This topic is closed to new replies.

Advertisement