[QUOTE=Dlaor-guy;31160154]Today, I optimized my space shooter/dungeon game to hell and back. Get ready for a huge wall of text:
My dungeon manager (actually a GridManager, but I'll call it a dungeon manager for now) used to consist of Grid entities which all contained a physical body: a simple rectangle. I thought to myself: that wouldn't slow down the physics engine too much, would it? Well, I was wrong. If I wanted to have my dungeon look actually large, it'd need to be at least 80x80 blocks. In the worst case scenario, that's [b]6400 bodies[/b]. Of course, no body is created if there's a hole in the grid somewhere, but still, my CPU didn't like that at all :v:
My first thought was: make one huge body, that contains all the rects in the dungeon manager merged together into one big concave polygon. That didn't work either, because the polygon became so big that it started to become corrupt: edges crossing each other, infinite lengths, etc. I fixed it by looping through the block list and creating a new body + concave polygon for every x value, so the dungeon consisted of large vertical slices. This was pretty much perfect, because the polygons didn't become large enough to get corrupt, but they were still large enough to make the whole simulation run a lot faster: now there were only [b]80 bodies[/b], instead of 6400!
The only disadvantage is that the initial process of merging all the rects on every column is very slow, so the loading times per-dungeon will be pretty long. But I think everyone prefers loading bars over slow in-game performance!
(I should probably get a blog)[/QUOTE]
Alright, as it turns out, this solution is far from perfect. It turns out that Polygon.CheckPolygon() returns true WHEN THERE'S AN ERROR. So that means all my polygons are invalid. :suicide:
Then I came up with another solution: simply merge rectangles together! (I made it sound a lot simpler than it actually is)
Before:
[img]http://i.imgur.com/AfKc1.png[/img]
After:
[img]http://i.imgur.com/sD3To.png[/img]
Quite efficient if you'd ask me!
[img]https://github.com/doomcat/c25km/raw/master/screenshot.png[/img]
I wrote an app to help me with my [url=http://www.c25k.com/]"Couch to 5k"[/url] jogging routine. It's written in python+pygame, with custom UI classes i've written. I wrote it for my Nokia N900, which is a Maemo device. It'd be cool if someone could [url=https://github.com/doomcat/c25km]fork it on GitHub[/url] and figure out how to make it run on Android devices, 'cause it'd be neat to see other people using it :) barely anyone has a Maemo device nowadays.
It's written to at least scale to whatever screen resolution the device is running at (and runs fullscreen), but I'm not sure whether the audible cues (which use text-to-speech synth programs like 'espeak' and 'say' (was testing it on my mac)) will work in Android variants, unless Android has an espeak package?
EDIT: oh and it could be used for any kind of running routine, if you modify the contents of 'workout.py'. And I know there's probably much better apps out there for this sort of thing. But not for Maemo, nobody loves Maemo. :v:
[QUOTE=Dlaor-guy;31171091]Alright, as it turns out, this solution is far from perfect. It turns out that Polygon.CheckPolygon() returns true WHEN THERE'S AN ERROR. So that means all my polygons are invalid. :suicide:
Then I came up with another solution: simply merge rectangles together! (I made it sound a lot simpler than it actually is)
Before:
[img]http://i.imgur.com/AfKc1.png[/img]
After:
[img]http://i.imgur.com/sD3To.png[/img]
Quite efficient if you'd ask me![/QUOTE]
What algorithm did you use for finding those rectangles?
How can I convert D3DCOLOR to D3DCOLOR_XRGB ?
Or should I say a hex number 0xFFFFFFFF to four int (255,255,255,255) ?
[QUOTE=AntonioR;31171729]How can I convert D3DCOLOR to D3DCOLOR_XRGB ?
Or should I say a hex number 0xFFFFFFFF to four int (255,255,255,255) ?[/QUOTE]
Each hex digit corresponds to four bits, each double digit (i.e FF) corresponds to eight bits, or one byte. One byte is the size of each piece of colour data (0-255).
With this knowledge, you can extract each bit of data using AND and bit shifting
[cpp]R = (hex & 0xFF000000) >> (6 * 4);
G = (hex & 0x00FF0000) >> (4 * 4);
B = (hex & 0x0000FF00) >> (2 * 4);
A = (hex & 0x000000FF) /* >> (0 * 4) (not needed here obviously) */;[/cpp]
If you don't understand how this works, take a look at the bitwise AND operation and how it works, and visualise the hex string as a binary number (i.e, the hex is 11111111 and we're ANDing it with 11000000 to get the red component and so on)
Edit: Oops, put the wrong values for my bitshifts. Fixed now I think...
[QUOTE=AntonioR;31171729]How can I convert D3DCOLOR to D3DCOLOR_XRGB ?
Or should I say a hex number 0xFFFFFFFF to four int (255,255,255,255) ?[/QUOTE]
The number looks like this 0xAARRGGBB, where A, R, G, B is in range 0x0 - 0xFF (0 - 255)
If you want to extract say only the RR (Red) part of it, you need to use some bitwise logic.
Here's how I'd do it (C-style language):
[cpp]
unsigned int color = 0xFFFFFFFF; // White (255, 255, 255, 255)[A, R, G, B]
unsigned char alpha = color >> 24;
unsigned char red = (color >> 16) & 0xFF;
unsigned char green = (color >> 8) & 0xFF;
unsigned char blue = color & 0xFF;
[/cpp]
[editline]17th July 2011[/editline]
Ninja'd.
[img]http://www.1337upload.net/files/Valokuva0308_edit.jpg[/img]
Got Wii to load & show a bmp image.
Oh, I assumed it was RRGGBBAA, not AARRGGBB format. Well, to fix that is pretty simple, so I won't bother editing my post again!
[QUOTE=Chris220;31171858]Oh, I assumed it was RRGGBBAA, not AARRGGBB format. Well, to fix that is pretty simple, so I won't bother editing my post again![/QUOTE]
Now he got both versions, so he can pick whatever he needs. ;)
[QUOTE=Chris220;31171779]Each hex digit corresponds to four bits, each double digit (i.e FF) corresponds to eight bits, or one byte. One byte is the size of each piece of colour data (0-255).
With this knowledge, you can extract each bit of data using AND and bit shifting
[cpp]R = (hex & 0xFF000000) >> (6 * 4);
G = (hex & 0x00FF0000) >> (4 * 4);
B = (hex & 0x0000FF00) >> (2 * 4);
A = (hex & 0x000000FF) /* >> (0 * 4) (not needed here obviously) */;[/cpp]
If you don't understand how this works, take a look at the bitwise AND operation and how it works, and visualise the hex string as a binary number (i.e, the hex is 11111111 and we're ANDing it with 11000000 to get the red component and so on)
Edit: Oops, put the wrong values for my bitshifts. Fixed now I think...[/QUOTE]
3 * 8, 2 * 8, 1 * 8 and 0 * 8
At least to me, using the number of bytes makes more sense than the number of nybbles.
[QUOTE=ZeekyHBomb;31171947]These should be 3 * 8, 2 * 8, 1 * 8 and 0 * 8, not the weird values you have there.[/QUOTE]
I think he used that to show that each digit is 4 bits, and he is traversing 2 digits at a time hence the 6, 4, 2.
[QUOTE=ZeekyHBomb;31171947]3 * 8, 2 * 8, 1 * 8 and 0 * 8
At least to me, using the number of bytes makes more sense than the number of nybbles.[/QUOTE]
Yeah I did it that way for what Ziks said, I was trying to show that each digit of the hex string is 4 bits, and because we're traversing 6 of them for the R, it's 6 * 4
Your way makes sense as well, but I figure that either of them are better than just having 24, 16 and 8 :v:
[QUOTE=Simspelaaja;31171848][img]http://www.1337upload.net/files/Valokuva0308_edit.jpg[/img]
Got Wii to load & show a bmp image.[/QUOTE]
For the benefit of anyone who hasn't been around long enough to get this
[quote=CarlBooth;19576449][img]http://i45.tinypic.com/1zvbzbr.png[/img][/quote]
[QUOTE=Simspelaaja;31171848][img]http://www.1337upload.net/files/Valokuva0308_edit.jpg[/img]
Got Wii to load & show a bmp image.[/QUOTE]
Did you make the image out of pixels?
I made a simple chat to try out .NET networking.
[img]http://i.imgur.com/uYS98.png[/img]
[QUOTE=Dlaor-guy;31160154]My dungeon manager (actually a GridManager, but I'll call it a dungeon manager for now) used to consist of Grid entities which all contained a physical body: a simple rectangle.[/QUOTE]
Grid tiles as bodies in a physics simulation? That doesn't make much sense to me. I could imagine using physics on [i]mobile[/i] objects in the dungeon, but I don't see how a fixed grid needs physics. Are the floor tiles sliding around or something?
[QUOTE=Dlaor-guy;31160154]I thought to myself: that wouldn't slow down the physics engine too much, would it? Well, I was wrong. If I wanted to have my dungeon look actually large, it'd need to be at least 80x80 blocks. In the worst case scenario, that's [b]6400 bodies[/b].[/QUOTE]
I'm not really experienced with physics simulators, and this might not even be applicable since I don't know what you're using physics for, but I recall reading in the [url=http://www.ode.org/]ODE[/url] documentation that bodies can be "disabled" when they aren't moving, so that the physics simulator can ignore them while stepping. Since most things are not moving all the time, this can greatly reduce the number of potential interactions the simulator has to consider.
Basically when you detect a collision you'd enable both bodies, and when a body stops moving (velocity below a certain threshold over a few frames) you'd disable it again. I think ODE can do one or both of those things automatically.
I am going back to beginner XNA programming.
Disclaimer: Comic sans is used for fun
[img]http://gyazo.com/639e2f46683170e2e249abf94e192aee.png[/img]
The text is at the position of the mouse, with offset controlled by WASD.
If I press space, the offset resets and if I press escape the program terminates.
Programs don't have to look good to be here, right?
[QUOTE=uitham;31173166]I am going back to beginner XNA programming.
Disclaimer: Comic sans is used for fun
[img]http://gyazo.com/639e2f46683170e2e249abf94e192aee.png[/img]
The text is at the position of the mouse, with offset controlled by WASD.
If I press space, the offset resets and if I press escape the program terminates.
Programs don't have to look good to be here, right?[/QUOTE]
no, but we do expect you to take at least the time to change the default corn flower blue XNA background.
[QUOTE=ColdFusionV2;31173223]no, but we do expect you to take at least the time to change the default corn flower blue XNA background.[/QUOTE]
Don't listen to this guy he doesn't know what he's talking about
[editline].[/editline]
That came out wrong, what i mean is the clear color isn't really top priority in a "game" like that, so there's no real reason to change it.
[QUOTE=ColdFusionV2;31173223]no, but we do expect you to take at least the time to change the default corn flower blue XNA background.[/QUOTE]
If the default was another color I would change it to cornflower blue anyways. It is a nice color.
[QUOTE=Wyzard;31172747]Grid tiles as bodies in a physics simulation? That doesn't make much sense to me. I could imagine using physics on [i]mobile[/i] objects in the dungeon, but I don't see how a fixed grid needs physics. Are the floor tiles sliding around or something?[/QUOTE]
I think the floor tiles are static bodies, used to detect collisions between the ship and the world.
[QUOTE=Maurice;31165668]
Anyone up for giving mario a portal gun?
[img]http://i.imgur.com/x6ahV.png[/img][/QUOTE]
I'm doing it right now. :v:
[editline]17th July 2011[/editline]
Wait, I thought you couldn't submerge the portal device in liquid?
[QUOTE=Garb;31173422]I'm doing it right now. :v:
[editline]17th July 2011[/editline]
Wait, I thought you couldn't submerge the portal device in liquid?[/QUOTE]
Even partially?
[editline]17th July 2011[/editline]
Damn, I'll reserve this space for some content.
I'm making a built in editor too.
[quote][img]http://i.imgur.com/gpYOA.png[/img][img]http://i.imgur.com/gRKz1.png[/img][/quote]
I started this a few days ago, so far I have a component-based entity system and some sick platform physics.
In the editor, you can only modify entities that are already built, so next up is creating and deleting entities.
[QUOTE=Vampired;31173807]I'm making a built in editor too.
I started this a few days ago, so far I have a component-based entity system and some sick platform physics.
In the editor, you can only modify entities that are already built, so next up is creating and deleting entities.[/QUOTE]
Guys, GLEED2D and Tiled exist for this reason.
It's much easier to write an XML converter/loader than it is to write a map editor.
Writing your own map editor is fun, not massively difficult and gives you functionality that suits your game/engine. What's not to like?
[QUOTE=neos300;31173929]Guys, GLEED2D and Tiled exist for this reason.
It's much easier to write an XML converter/loader than it is to write a map editor.[/QUOTE]
I much prefer to do things like this myself personally, and i agree with chris
[QUOTE=thomasfn;31173319]I think the floor tiles are static bodies, used to detect collisions between the ship and the world.[/QUOTE]
Ah, that makes sense. But then why not just have a single large static body for the whole floor plane? No need to divide it up on grid boundaries when the grid is just for drawing and has no physical meaning. Just take the dungeon's bounding rectangle and make it a body.
(The situation would be different if different grid tiles could have different heights, but I'm guessing that isn't the case.)
[QUOTE=neos300;31173929]Guys, GLEED2D and Tiled exist for this reason.
It's much easier to write an XML converter/loader than it is to write a map editor.[/QUOTE]
Boooring
Here you go Maurice:
[IMG]http://i869.photobucket.com/albums/ab255/Yournameisinvalid21/Mari0Sheet.png[/IMG]
Also: Singular portal device for when he dies ( I actually couldn't get it to look right, so I figured you could make him drop it, or do whatever you wanted (I thought it would be kinda funny if it went flying or something))
[IMG]http://i869.photobucket.com/albums/ab255/Yournameisinvalid21/portalgun.png[/IMG]
Woah thats tiny.
Sorry, you need to Log In to post a reply to this thread.