Jump to content

  • Log In with Google      Sign In   
  • Create Account

JTippetts

Member Since 04 Jul 2003
Offline Last Active Today, 08:39 PM

#4998601 sfml problem/question regarding VideoMode

Posted by JTippetts on 07 November 2012 - 03:52 PM

What FLeblanc and I mean when we say "native resolution" is that every LCD monitor has a recommended resolution, dependent upon the monitor's size and quality. Using this recommended resolution means that there is a 1:1 correspondence between a "logical pixel" (what resides in the frame buffer) and a physical pixel (the actual bit of screen hardware that displays a pretty color). Choosing a resolution that is not the recommended resolution means that logical pixels can be spread across multiple physical pixels, resulting in blurring and shimmering artifacts as the picture moves.

By default, a game should detect optimal resolution by default (going with a user's current desktop resolution is probably best, since it will usually be the optimal setting) but present a dropdown box of alternative, allowable modes they can choose from if they have performance problems or other personal reasons to switch. But my personal opinion is that you shouldn't force a player to a non-optimal fullscreen resolution by default, and any game that does is likely to earn my ire.


#4998463 How to avoid singleton

Posted by JTippetts on 07 November 2012 - 10:51 AM

Why does there need to be a concrete Fireball class anyway? A fireball is just a projectile with an exploding component that does fire damage. Object composition is your friend. By creating concrete classes like that, you limit your options and make a lot more work for yourself in trying to shoehorn everything in. What if you want an Iceball spell? You could create an Iceball class, duplicate some code from Fireball and change some things around, or inherit from a base class... but all of that is a code smell that ultimately leads you into a bad place of spaghetti code that can kill your project. Why not construct a composition system, instead? Break it down into individual behaviors, and add those behaviors to an object as it needs them.
Here is the gist of how I construct a fireball spell in Goblinson Crusoe:

1) Create an Object. An Object is an empty canvas; at this point, it could be anything.
2) Add a projectile component. Now, the object is a thing that moves from one place to another, and when it gets where it's going or hits something along the way, it sends itself a message that it has collided. It listens for logic update messages to know when to move. Lots of spells would share this component: fireball, ice spear, thrown rock, shot arrow, etc...
3) Add an animation component. Now, the projectile has a visual presence in the world, a looping animation of a fireball streaking through the air. Lots of spells would share this component, too.
4) Add an explosion damage payload. This component listens for the notification that is has collided with something, and when it receives such a message it will query the world for all other objects within a specified radius, and deliver a packet of Fire damage to each one. Some spells might use this area-effect payload, others might use a single-target-damage payload. Others might use a heal-target payload, or a heal-area payload. Still others might use a polymorph-other payload. Whatever; this component describes what happens when the thing hits something.
5) Add a Flash component, which also listens for a collided notification and spawns an explosion animation.
6) Finally, add a terminator component that also listens for collided, and sends the object a message to die.

At any step along the way of constructing this object, you can tweak things. Change the damage type to Ice and the animations to iceball and ice explosion. Add a component that spawns additional projectiles for damage debris or ember shards that strike additional enemies. Add a component that spawns 100 little floating daisies to settle out of the fire-seared air onto the scorched earth. Change the projectile component type to tracking rather than straight-line, in order to hunt down and destroy. Change the Flash animation to a nuke going off, for extra visceral effect. You name it. You are not limited to just one generic type of fireball. And there are no singletons to be seen anywhere in that scenario.


#4998165 sfml problem/question regarding VideoMode

Posted by JTippetts on 06 November 2012 - 01:25 PM

You can use VideoMode::getFullscreenModes to get a vector of all valid (fullscreen) modes. If you require a resolution that is not supported then you can do as you suggest, and just draw to a sub-section of the window. Just check the enumerated mode for the next largest valid mode, or use native resolution, and center your active area. Be aware that this may annoy your players, some more than others. For such a small window, given the native resolution of modern LCD monitors (and you should try to stick to native resolution, for image quality) 800x600 will amount to more black-space than used-space. I would certainly complain about a game that did that. I highly recommend you do what you can to use a higher active resolution.

For windowed mode, 800x600 shouldn't be a problem.


#4996978 How to find the closest interception point?

Posted by JTippetts on 03 November 2012 - 03:26 PM

Maybe this thread might be of some use:

http://www.gamedev.net/topic/614147-enemies-leading-their-shots/

It talks about leading shots on enemies, and one poster presents a solution to the shot-leading problem by solving a quadratic equation.


#4996714 Who would consider a game interface an art?

Posted by JTippetts on 02 November 2012 - 06:07 PM

Once upon a time, art wasn't really a word or a thing. People made stuff, that's it. Cave paintings, carved sticks, whatever. They didn't make it to be all hoity-toity in their stupid art magazines. Grok didn't look over at Blorg and say, "Blorg make carved stick, not rock people; carved stick not art. Blorg dumb." Blorg was probably dumb, but Grok's no-carved-sticks-are-art rule was still stupid. If some ass-hat can crap in a can and call it art, then game interfaces can be called art as well. Your average game interface certainly takes more creativity and skill to create than pooping in a tin can.


#4996599 Why is this terrain using 4d simplex noise not tiling?

Posted by JTippetts on 02 November 2012 - 11:03 AM

Yes, loopx0 and loopx1 are constant. If you were to map the range specified by loop to the entire map all at once, that map would tile with itself. mapx0 and mapx1 are specified as sub-ranges of loop, and correspond to each sub-chunk of the map. So if the loop range is 0 to 1 and there are 10 sub-chunks across the map, mapx0 for the first chunk would be 0, mapx1 would be 0.1. For the second chunk, mapx0 would be 0.1, mapx1 would be 0.2. But for all chunks, loop would be the same.

Now, there is a problem with mapping the range [0, tilewidth*numberoftiles] to loop. Say your tile width is 64 and you have 100 tiles. This means the looping range would be 0 to 6400. Mapping this range of noise does not produce anything meaningful, basically just white noise, unless you turn the frequency of the noise function WAY down. This is because, in Perlin noise (gradient as well as simplex, even the value-noise variant) there is roughly 1 "feature" per integral coordinate at the default frequency of 1. This means that in the range 0,6400 there would be produced approximately 6400 "hills" or "valleys". The output would be very much like the third screenshot in your original post. You need to turn down the range specified in loop to correspond what you wish to map.


#4995601 Why is this terrain using 4d simplex noise not tiling?

Posted by JTippetts on 30 October 2012 - 04:41 PM

It's a little tough reading your code, since it seems the forums ate your newlines, so correct me if I'm wrong about what you are trying to do.

1) You have an array of tiles, tiles indexed on i and j.
2) Each tile is a chunk of noise, the individual pixels of which are indexed on localx and localy.
3) You want to calculate each pixel of the tiles such that the whole map tiles seamlessly with itself

For reference, here is how the 2D tiling noise in ANL is constructed:
 {
	    size_t w=a.width();
	    size_t h=a.height();
	    static double pi2=3.141592*2.0;
	    size_t x,y;
	    for(x=0; x<w; ++x)
	    {
		    for(y=0; y<h; ++y)
		    {
			    double p=(double)x / (double)w;
			    double q=(double)y / (double)h;
			    double r;
			    double nx,ny,nz,nw,nu,nv,val=0.0;
			    double dx, dy, dz;
			    dx=ranges.loopx1-ranges.loopx0;
			    dy=ranges.loopy1-ranges.loopy0;
			    p=p*(ranges.mapx1-ranges.mapx0)/(ranges.loopx1-ranges.loopx0);
			    q=q*(ranges.mapy1-ranges.mapy0)/(ranges.loopy1-ranges.loopy0);
			    nx=ranges.loopx0 + cos(p*pi2) * dx/pi2;
			    ny=ranges.loopx0 + sin(p*pi2) * dx/pi2;
			    nz=ranges.loopy0 + cos(q*pi2) * dy/pi2;
			    nw=ranges.loopy0 + sin(q*pi2) * dy/pi2;
			    val=m.get(nx,ny,nz,nw);
				 
			   
			    a.set(x,y,val);
		    }
	    }

Now, comparing your code, these lines where you calculate your noise input coords look suspicious to me:

nx = absx + Math.cos(s * 2 * Math.PI)*dx/(2*Math.PI);		  
ny = absy + Math.cos(t * 2 * Math.PI)*dy/(2*Math.PI);		  
nz = absx + Math.sin(s * 2 * Math.PI)*dx/(2*Math.PI);		  
nw = absy + Math.sin(t * 2 * Math.PI)*dy/(2*Math.PI);

absx and absy are calculated as the global pixel coordinates of the sample, so they are going to change in value as the pixel coords change. In my original implementation, I use loopx0 and loopy0 here, which do not change. The only way the coordinates change is through the value of s and t, which should be calculated from the pixel coords.

In my implementation, I specify the ranges over which the noise loops explicitly, rather than tying the range to the tile coordinates. Similarly, I specify the ranges over which the tiles are mapped explicitly. The ranges loopx0 to loopx1 and loopy0 to loopy1 specify the range of noise mapped to the entire map. The ranges mapx0 to mapx1 and mapy0 to mapy1 specify the range of noise (a sub-range of the larger looping range) to map to a given tile. This would be calculated by dividing the larger loop range up into as many equal-sized pieces as there are tiles.

As far as getting different terrain, I implement a seeding technique where a seed is passed as another input to the noise function, and is hashed together with the input coordinates. Change the seed, get a different output.


#4994925 pong paddle

Posted by JTippetts on 28 October 2012 - 09:25 PM

You can import it into Gimp, color-select the white background, and fill it with black.

My suggestion is that you avoid using JPG for sprites, though. Typically, a sprite is going to have transparent areas, and JPG doesn't support alpha channel. Also, JPG compression is lossy, so you can lose detail. I'd suggest going with PNG, TGA or some other format that supports loss-less compression and a alpha channel.


#4994853 How do I avoid hundreds of identical scene graph traversals?

Posted by JTippetts on 28 October 2012 - 04:45 PM

Instead of each node pulling from its parent (which in turn pulls from its parent), push instead. Calculate the root node's transforms first, then push them out to all children, who will calculate their transforms and push to their children in turn.


#4994634 Why does this look so flat?

Posted by JTippetts on 27 October 2012 - 10:45 PM

If you're not yet skilled at pixel art, one trick you can do is to draw it several times larger than you want it to be, then scale it down to the size you need. If you are not good with form, you can try modeling with simple 3D shapes in something like Blender, then tracing over it with pen tools in Gimp to provide strokes and outlines. A quick (and pretty crappy) example of both techniques:

Posted Image

The anchor was quickly modeled by dragging some points in Blender and doing a Skin modifier plus a subdivision surface, then rendered and quickly traced with some outline, then scaled down. Working from a 3D render like this can also help you to work on your own hand-shading if that is the way you really want to go. The 3D render gives you a template to work from, and you can draw and shade on a layer over the top of it to practice your skills.


#4994550 Is it possible to draw Bezier curves without using line segments?

Posted by JTippetts on 27 October 2012 - 04:08 PM

I understand that I can subdivide the curve down so that I am drawing single pixel lines, but that is again drawing lines. What I am looking for is Bezier curve code that draws a Bezier similarly to Bresenham's line drawing code. In other words, the initial pixel is calculated and the rest are incrementally derived from some function. The curve would be plotted pixel by pixel by pixel.

My interest in this is really just personal. I have no need for it, but it always bothered me that I could not find any examples. I am just really curious if this has ever been done, and if so, I would like to see the code.


Well, if your line segments are only a single pixel long they're... uh.... just pixels. They're sequentially plotted from the function that is the Bezier curve. You're probably not going to find something as simple and elegant as a Bresenham algorithm for Bezier curves because the curvature is neither constant like a circle, nor easily predictable like an ellipse. You could possibly derive it to obtain the curvature (the curvature can be described as the rate of change of the tangent to the curve with respect to the arc-length, or dT/ds) and match curvature to a pixel pattern, but that just seems needlessly complex. Some quick googling turned up http://www.gamedev.net/topic/156180-curvature-of-a-bezier-solved/ in which a poster posted about how to find the curvature of a Bezier; couldn't say how accurate or correct it is, but it might be a place to start. Seems like, if you know the curvature at pixel N, then you should be able to use it to calculate pixel N+1. But, again, it's probably just easier to evaluate the curve for very small increments of t instead.


#4994546 Are you planning/making a Windows 8 (metro) app?

Posted by JTippetts on 27 October 2012 - 03:59 PM

I am actually planning to stop programming when 9 comes out. I don't like gatekeepers, and when they're forced on me, I'll find something else to spend my time on. The field is moving on, going into places I'm not comfortable following. Just getting old, I guess.


#4994479 Are you planning/making a Windows 8 (metro) app?

Posted by JTippetts on 27 October 2012 - 12:48 PM

You forgot "hell no."


#4994136 Ethics of Placeholder Art

Posted by JTippetts on 26 October 2012 - 07:46 AM

I find it odd that anyone would need comments on their interface if it was using placeholder anyway. Wait until you have elements of your own before you show it off, otherwise it only means that the original design team did a good job, and you know how to copy paste. What's the point of that?


#4993980 Codeblock ISO scoping problem

Posted by JTippetts on 25 October 2012 - 06:41 PM

You have a semi-colon after your for(unsigned int q=... line, which terminates the loop at the line, rather than looping through the block. Everything in the block that tries to use q then violates the rule that you shouldn't use a variable declared locally to a block or loop like that after the loop terminates. Also, later, you try to reference i, which doesn't exist. (Probably need to change that to q, after you eliminate the semi-colon).




PARTNERS