Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

OK. here's my idea:

 

I want to make some tilebased game, were the user/player can place structures on the map. I am pretty sure you have seen this before: There are some green squares under the "not yet placed structure". If i now move the mouse over a rock, some of the squares (the ones overlapping the rock) change to red, showing the player he cant place it there. I guess thats it.

 

And heres my problem:

 

Earlier i moved my sprite by destroying the vertexbuffer and recreated it with different vertex coordinates. I figured this was VERY inefficent, so i learnt how to move the world. Now, in the very same piece of code, while filling the vertexbuffer, i set a color. How can i change this color "in game" without destroying and recreating the vertexbuffer?? I dont want to recreate the vertexbuffer as this was extremely inefficent.

 

Got any ideas, links, suggestions or code snippets?? please post them here...

 

EDIT: When i use a color when filling the buffer, the result is only a lighter or darker square. Not even a glimpse of a color :confused:

 

-- Loffen

Erutangis a si tahw
Posted

Here's an idea: Try using Lighting to light that particular square :).

Hmm.. I guess d3d is weird when it comes to texturing PLUS using colors.. I'll experiment around with that, maybe you need to get the latest DirectX.

 

-The Pentium Guy

My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!)

vbprogramming.8k.com

My Project (Need VB.NET Programmers)

http://workspaces.gotdotnet.com/ResolutionRPG

Posted
maybe you need to get the latest DirectX.

 

Whats the latest?? I got 9.0c.. thought that was tha latest :confused:

 

EDIT: hmm... lightning... could add a nice scary atmosphere. Does this work in 2D??

 

-- Loffen

Erutangis a si tahw
Posted

You'd have to mess lighting with it a bit for it to work with 2d.

Also you'd need normals.. set the .Normal or the .RHW property of your vector3's to 1.

 

Yep 9.0c is the latest versoin.

My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!)

vbprogramming.8k.com

My Project (Need VB.NET Programmers)

http://workspaces.gotdotnet.com/ResolutionRPG

Posted (edited)

I have been playing around with different textures, colors and different ways of adding the color to the vertex. Well, my english is too bad to tell how confused my head is right now.. will post 2 screenies from app to make things clearer.

 

The first one:

* The upper-left tiles are the images in original state.

* The "map" has the color integer set to 65000.

 

As you see, the green looks 100% the same, but the pink gets blue !?!?!?!

 

The secund one:

The same map as the first one but the color is now added like this:

Color.FromArgb(155, 200, 0, 0).ToArgb

 

What i expected from this was that all squares get red (actually 50% transparent red)....

EDIT: BTW: as you might want to know, my backbuffer format is Format.A8R8G8B8. Shouldnt this allow me to create transparent colors??

 

Any suggestions? Tips?

 

--Loffen

Edited by Loffen
Erutangis a si tahw
Posted

Here's another idea, if you want all squares to get 50% red:

 

Create a 50% red bitmap (alternate every pixel.. red green red green.. assuming green is your transparent color). Must be a real pain to do this... heh... I guess it would work though.

 

-The Pentium Guy

My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!)

vbprogramming.8k.com

My Project (Need VB.NET Programmers)

http://workspaces.gotdotnet.com/ResolutionRPG

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...