Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C# OpenGL mapping
Hi,
 
I am currently trying to develop a 2D game, but I came through a little problem. I would like to hear some answers from the experienced game developers.
 
So let's say I have a wall texture. A player shoots a bullet on it, then how do I draw the bullet texture on that wall texture? Later if I want to use the same texture, how do I use that exact same wall texture (without the bullet) on another wall object?
 
How do game developers usually do this?
Posted 5-Jan-13 1:50am
velvet71.1K
Edited 5-Jan-13 4:38am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I'm not a game developer, but I'm trying to answer your question.
 
There are different methods to display the above scene.
Before preparing your scene you can place all objects in proper place.
 
Quote:
A player shoots a bullet on it, then how do I draw the bullet texture on that wall texture?

 
My suggestion is to redraw the scene with the background scene(wall) and bullet. You can retain the wall texture without any change. Draw objects(bullets) on top of backbground(wall).
 
DrawScene()
1. Draw Wall Texture.
2. Draw Bullets( this drawing will be on top of wall ).
  Permalink  
Comments
JackDingler at 9-Jan-13 15:14pm
   
That's essentially it.
 
the technology you're looking for is called, 'decals'.
velvet7 at 9-Jan-13 15:32pm
   
This is exactly what I tried to do. The problem comes when I try to draw on the boundary of the wall. So imagine it like this:
*
---***-
| * |
| |
-------
 
Where the * is the bullet texture. Basically it draws "in the air", which I want to avoid.
JackDingler at 9-Jan-13 17:20pm
   
Research 'decals'. Its a technique for overlaying one texture on top of another. It has been developed to do exactly what you want.
 
There's no quick answer for this, but it's a common technique and many articles have been written on it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 390
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100