Mouse issues and maybe a few ideas?

Feb 26, 2011 at 9:24 PM

First off, FANTASTIC little engine.

I however am a little put off with the mouse keyboard relationship. I love the moving vantage with mouse but would like to see some button implimentations.

Are you guys working on a way to save the current region?

Also, Jump seems really unrealistic. I think thats the first thing I am going to look into changing.

Bu great app :D


Oh and FINALLY! Thanks for the xna 4.0 port over. Been waiting for that.

Feb 26, 2011 at 9:34 PM
Edited Feb 26, 2011 at 9:40 PM
for the jump, i commented it ( because swimming is not enabled, I was always stuck on the sea bottom)  !

look in the player class :

//XXX fly mode
//if (_world.SolidAtPoint(footPosition) && _playerVelocity.Y == 0)

for the mouse buttons, bamyazi was more into the xbox version at first

=> try to patch the code yourself, search for keyboard mappings E and Q. and send us the patch (or as an answer here ! )

just search for XXX to see all places where I changed the original code, except for the xna 3.1 to 4.0 necessary changes, and the terrain implem in gameclient.cs.

Feb 26, 2011 at 9:41 PM

And yes, we are working on the region system .

Feb 26, 2011 at 10:18 PM

OK implimenting the mouse buttons was uber easy:

Added the mousestate check state here:

public void CheckBuild(GameTime gameTime) 


----->            MouseState mouseState = Mouse.GetState();


And then added the appropriate or statements for the mappings for Q and E

if (_game.InputState.IsButtonPressed(Buttons.LeftTrigger, _game.ActivePlayerIndex, out controlIndex) ||  

           _game.InputState.IsKeyPressed(Keys.E, _game.ActivePlayerIndex, out controlIndex) ||    

---->     mouseState.RightButton == ButtonState.Pressed)


 if (_game.InputState.IsButtonPressed(Buttons.RightTrigger, _game.ActivePlayerIndex, out controlIndex) || 

               _game.InputState.IsKeyPressed(Keys.Q, _game.ActivePlayerIndex, out controlIndex) ||

---->         mouseState.LeftButton == ButtonState.Pressed)

I am going to check the jump code now.

Thanks for the quick response by the way. My name is Paul.

Feb 26, 2011 at 10:27 PM

I see what you were saying about the water. With the player jump distance set to 6f they only jump that far under water as well. 

In a way I can see how thats a pain but on the other hand with no limitations on building materials and life at the moment its really not that big of a deal. :)

Feb 27, 2011 at 7:08 PM

I committed it , plus a few small fixes  like the debug.font that was missing (debug * resources are ignored so i renamed it to console.font). Now the project works immediately from checkout ( 'clone' in mercurial terms) . 

As always, nothing ever takes 5 minutes  in development , to make it work correctly I had to check the previous mouse state  too ( there is no ButtonState.clicked , only pressed / released ! ) 

and while i was at it, I did add the block selection with mouseWheel too .

Feb 27, 2011 at 10:03 PM

You should be able to get swimming to work by disabling the check to ensure you are standing on a block in the jump code when you are underwater.

If i remember correctly there is already an _isUnderwater flag, which is used to identify when to generate bubble particles and add the blue overlay.

Feb 27, 2011 at 10:44 PM


So I got the mouse working but the mouse clicks were insanely quick. So clicking on a block removed 3 or 4 rather then just one. I had to impliment a catch. Code below:

In the declarations:

private MouseState mouseStateCurrent;
private MouseState mouseStateCurrentLeft;
private MouseState mouseStatePreviousLeft;
private MouseState mouseStateCurrentRight;      
private MouseState mouseStatePreviousRight;

In the  

Update method:

mouseStateCurrentLeft = Mouse.GetState();  
mouseStateCurrentRight = Mouse.GetState();

if (mouseStateCurrentLeft.LeftButton == ButtonState.Pressed && mouseStatePreviousLeft.LeftButton == ButtonState.Released) 
mouseStatePreviousLeft = mouseStateCurrentLeft;
if (mouseStateCurrentRight.RightButton == ButtonState.Pressed && mouseStatePreviousRight.RightButton == ButtonState.Released)      

mouseStatePreviousRight = mouseStateCurrentRight;                           

Now you might notice I stopped calling the CheckBuild other then that. This of course negated the "Q" and "E" keys but I am ok with that.


Lets see, also added a bunch of new sounds and some logic to determine what block plays what sound.
I got rid of the bazooka. Nice... but not the effect I am going for :-P

Now please guys, dont be to critical of my coding skills. Im a vb guy. Started coding 20 years ago in QB, and been a basic coder ever scince then.
I know enough about c# to be dangerous but this is my first full fledge dive into c# so if you see a lot of newbie mistakes forgive me.


On another note. Anyway to invoke the lighting? When you encapsulate yourself in blocks it should be dark. But it is not. I tried the Lighting.Update method as blocks are added and or removed but that was kinda stupid as I think thats already been invoked.


bamyazi, I have seen the isUnderwater flag. I will give that swimming thing a shot. Thanks :)

Feb 27, 2011 at 10:46 PM

Oh? What did you do with block selection on mousewheel. Can I grab the code from you?

Feb 27, 2011 at 11:05 PM

I am thinking about a save, recall or crud operations. For games. I know you guys are working on it. I am not a file system kinda guy :-P So was thinking something more robust like say mysql. Thoughts?

My boyfriend is giving me a hand on this. He is more c# driven then I am. We looked breifly at your game building methods.... While I was there I implemented Iron and Gold insertion.

In the LandscapeMapGenerator.cs under the GenerateRockLayer I added:

          if (r.Next(50) == 1)        
                            _map[x, y, z] = BlockType.Iron;
else if (r.Next(100) == 1)                        
    _map[x, y, z] = BlockType.Gold;        


If you havent noticed yet, I am going for a complete Minecraft clone.

I love Minecraft, but would love to be able to impliment more features. So the plan for me is to get this as close to that as possible then work on new features.              

Feb 28, 2011 at 2:13 AM

I already solved the click problem  ( I think ;) and commited the code + mousewheel (blockpicker.cs) . You just need to store one previousmousestate.

The code is available here

we use mercurial as source control ( a new alternative to cvs, sourcesafe, tfs etc ... ) . Read this

 in fact to get the latest code and gain the ability to update it, you ll just have to install the software 'hgtortoise' and then do a 'clone' of


about LandscapeMapGenerator, I know it s way cooler and has trees, snow water than the terrain I added, but it was not designed for an infinite or large map .

The new terrain is able to create seamless regions independently, based on their position, and I kept it simple ( no water / trees) to test this infinite map system thats under developement (not available yet).

=> Dont invest too much time into landscapeMapGenerator it will be replaced !

Feb 28, 2011 at 2:56 AM

enomi - Thats awesome news. Any idea on a time frame?

I tried just using one mousestate and it freaked out on me. :-P Im going to see what you did.

I would love to use Mercurial - I just dont want to screw up what you guys are doing. Would it create a seperate tree just for what I am doing?

I really am disabling a lot of stuff and enabling a lot of new stuff so I wouldnt recommend anyone be using my code :-P That and im a c# newb. 

Thanks for the mousewheel.

I added a glass block just for fun but I am having problems with the transparency. The blocks.png has a new image basic white outline and transparent center. But the blocks show up as black. Any ideas what I am missing?

Feb 28, 2011 at 3:03 AM

Let me rephrase. The transparent area is showing up solid black. The outline shows up just fine.

Feb 28, 2011 at 3:24 AM

You wont be able to commit to the main branch, but you can create a public fork if you want ! So we ll  have the ability to pull your changes and vice versa. And we can all add mercurial on our resumes ;)

For the glass I know you ll have to use Blendstate.AlphaBlend instead of Blendstate.opaque. Search for alphaBlend you ll find the water effect ( water is transparent !)

You may have to reactivate the "model" class of blocks, see occurences of the word model in region.cs anf blockinformation.ismodelblock (and everywhere else ;)

And if you want to have fun, replace all instances of BlendState.opaque by BlendState.additive, i made this mistake when converting the code to xna4.

For the time frame it depends on bamyazi, I asked his help on this subject .  



Mar 1, 2011 at 2:37 AM

Hum, I just figured the good way to implement this would be in the inputState class. like this :

Mar 1, 2011 at 2:46 AM

enomi was there any UI out there you wanted to use or base for a UI for techcraft you could recommend?

Mar 1, 2011 at 4:19 AM
Its a good subject cause many indie games have a very poor UI, but sorry no idea. found some things by googling "xna ui hud inventory" but no time to research it for now.
Only requirement : It must be licensed under MS-PL to allow integrating it in our code.
I think UI should be decoupled from the engine, so you can have different types of UI for Xbox and Pc, and for different types of games.
For my own (nebulous and distant;) game project I may choose to have no Hud at all, just the mousewheel to select tools and everything being interactions with the world/map.