Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 22 Mar 2010
Offline Last Active Jul 18 2016 05:13 AM

Posts I've Made

In Topic: A Struct That Contains A Delegate With Unknown Signature

18 July 2016 - 05:15 AM

I got it working with this struct:

namespace commandLineOS {
    public struct Command {
        public string name;
        public string helpDoc;
        public Delegate commandDelegate;

This instantiation:

commands.Add(new Command { name = "help", helpDoc = "lists this help file", commandDelegate = new Action<List<Command>>(commandHelp) });

And this call:


I don't really understand what I did here or exactly why it's working but I am guessing I will need to use Func instead of Action if I want my command to return a value or take in more than one parameter.

In Topic: Spherical world for a 2D game

20 April 2015 - 08:31 PM

Thinking back a bit further in the history of my experience, I wonder if you could take inspiration from how old raycasters like Wolfenstien3D and Doom corrected the 'fish-eye' effect that results from computing ray distance from a central point, which they would then use to scale the vertical wall segment. That would produce some wierd visuals if left uncorrected, such as you would seem to be squared up to a nearby wall in the center of the screen (its floor and ceiling were flat and parallel), but as the rays marched towards the left and right extremes of the screen, the ray distance would accelerate towards infinity and cause the wall segment to shrink rapidly, pinching the floor and ceiling together. 


I wrote an ASCII ray caster and had to deal with that exact case. Funny thing is the effects were so hard to interpret in ASCII that I had to convert the engine to a standard per pixel graphical raycaster to see what was going on. Wasn't aware what the phenomenon was called until years later when I started reading all of Carmack's notes on the BSPs in Doom.

In Topic: Spherical world for a 2D game

20 April 2015 - 08:28 PM

It would mostly all be pointless though, as the player wouldn't have a very good sense of the overall shape being spherical in a 2d game.


3/4 of the way through this sentence it clicked that this is not a viable idea. They really won't have a good sense of the world at all. And anything that doesn't end up with some absurd case where they're at poles and the map is cycling around horizontally rapidly will end up having their orientation with respect to the axis of the sphere constantly changing and there will be nothing recognizable to them.


Not really... say that you're at the equator and walk left and right.. easy..


Then imagine walking straight up until you reach the pole, and then turning right. Do you want the player to walk "right" as in along the longitude, basically having the same tile repeat itself over the entire visible area, or do you want the player to walk "right" as in walking south along the latitude back towards the equator?


The problem with turning towards the equator is that "up" won't always be "north". If you walk up from the equator to the north pole, then turn right and walk back down to the equator, and then turn right again and continue right until you reach the original position where you started to walk "up", that direction (north) will now be to the right, not up.


I think the easiest solution would be representing the world as a real sphere, though I guess every time you scroll up/down or left/right you could dynamically map the new row or column of tiles that should scroll into view to a part of the sphere and then create the actual tiles as a 2D row/column instead of 3D. But again, they would not always have the same left/right orientation.


The issue you described is the problem I was trying to describe in the OP. Your solution is probably one of the better ones but as it's essentially ugly, it helps to highlight why I'm just going to have to end up going with a torus since a sphere won't work well at all.

In Topic: Random subset of list including specific element(s) in Python

02 January 2015 - 10:09 AM

Thanks all

In Topic: Random subset of list including specific element(s) in Python

02 January 2015 - 09:03 AM

Well that's how I've been doing it. What I don't like is that I have to take extra steps to re-insert that element into the sub-sample so that it's in a random location.


And just appending it then scrambling the sample seems wasteful since generating the sample already involved a permutation in the first place.


Is deleting wanted element, taking sub sample of remainder of list, appending wanted element to sub sample, and scrambling the sub sample really the best way to do it?


The way I'm appending it now is:


permuList.insert(randrange(len(permuList)+1), element)