• entries
    743
  • comments
    1924
  • views
    578744

Map.NET: Day Two

Sign in to follow this  
Aardvajk

93 views

[EDIT - Don't know much about distributing .NET apps. Could anyone with a couple of minutes spare try this and just let me know if it runs? Ta.]

Map.NET continues pretty well. I've got a virtual scrolling area working now and an actual MapGrid class that stores the IDs of the cells. The scrolling area only draws the visible cells, but does pixel scrolling so looks quite cool. It also means that while it is a bit laggy compared to my C++ Map application, it is no more laggy with 1000x1000 cells than with 20x20.

I had to implement the virtual scrolling area using a PictureBox and a HScrollBar and VScrollBar though, which was dead fiddly. I really wish there was a .NET component like a VirtualScrollBox sort of thing, that provided system-managed scrollbars that you could just set the maximum values for and an OnScroll event that allowed you to paint manually to the client area, based on the H and V scroll positions.

If anyone knows of such a thing and could enlighten me, you'd make my day.

Anyway, so far so good. The next step is to allow the scheme file to generate a list of blocks with IDs and bitmaps, and make the values in the MapGrid refer to a block by ID, so the bitmap is drawn instead of the current blocks of solid colour. Going back in...

[LATER]

Aarrgh.

GDI+ does not currently support raster operations, apparently. So I can't draw a rectangle on the screen with a NOT operation. Bugger.

So I can't do a "rubber-band" selection rectangle without invalidating the entire PictureBox image on every mouse move.

I did try all this arcane interfacing with gdi32.dll stuff, but the program wouldn't run because of permissions or some such voodoo nonsense.

I tried just drawing a dotted rectangle and invalidating the PictureBox in the mouse move event and it seemed to work sort of okay, but I'm not happy.

[LATER STILL]

Actually, that works sort of okay. On a maximised window at 1280x1024 with 32x32 blocks, it runs at an acceptable pace. Slows a bit with 8x8 blocks at the same resolution, but I really don't know what else to do.

It only really works here because the selection rectangle is locked to the cell boundaries. If it was pixel-free, I suspect it would be even worse.

Actually drawing the selection rect as a hollow white rectangle with a 2pixel wide line and a black drop shadow. Seems to stand out okay against most colours.

I am very disappointed that GDI+ doesn't support raster ops though. It seems pretty extreme that you have to resort to unmanaged code to do this in C#. Even if I could get the security settings right for this on my own PC, I suspect that anyone else running my final application would get a load of scary warning messages.

I think I'm going to call it GDI- from now on [flaming].
Sign in to follow this  


4 Comments


Recommended Comments

Late to the party as usual, but I just tried out your Udo demo. Nice! It has a very subtle feeling of 'well-polished' even in such a short demo. The overall aesthetics are very pleasing to me.

The game is pretty responsive. The little guy has a bit of floatiness to him and that really helps navigating him in the air. My favorite part was the dying sound effect -- just because the last part of it sounds like a sound clip from 'Predator' =)

Hope progress keeps going smooth and steady!

Share this comment


Link to comment
Quote:
Original post by shadowcomplex
Late to the party as usual, but I just tried out your Udo demo. Nice! It has a very subtle feeling of 'well-polished' even in such a short demo. The overall aesthetics are very pleasing to me.

The game is pretty responsive. The little guy has a bit of floatiness to him and that really helps navigating him in the air. My favorite part was the dying sound effect -- just because the last part of it sounds like a sound clip from 'Predator' =)

Hope progress keeps going smooth and steady!


Thanks. Glad you like it.

Share this comment


Link to comment
It's true -- GDI+ drawing via WinForms is slow. For your rendering needs, something like SDL.NET (either via its software rendering, or OpenGL through it) should give you all of the speed that you need.

Share this comment


Link to comment
Quote:
Original post by HopeDagger
It's true -- GDI+ drawing via WinForms is slow. For your rendering needs, something like SDL.NET (either via its software rendering, or OpenGL through it) should give you all of the speed that you need.


I'll have to look into that. Can you use that to render into a control on a Windows Form and still have normal Windows Forms controls and stuff? Like with my map editor, could I just use SDL.NET to render the actual map view and still have the scrollbars and menu and everything else?

[EDIT] Just been on the link you posted and it looks like you can. I'll have to investigate this further. Cheers.

Share this comment


Link to comment

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