Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 28 May 2011
Offline Last Active Oct 11 2016 01:30 PM

#5267613 Draw only portions of the circle visible to the user

Posted by on 23 December 2015 - 02:54 AM

If your circles dont change significantly over time, and/or if you have many circles that look the same, draw the circle to an image and blit that to the screen, which should perform significantly better (you can update the image, even every frame if theres many circles sharing the same image and thus saving calculations).

#5267552 Compiling and running on different OpenGL versions

Posted by on 22 December 2015 - 04:41 PM

Most of the openGL functions you use, are fetched from at runtime in the form of a function pointer (see openGL wiki on function loading).


Usually youd use a helper library like GLEW to automatically do the loading (it declares all the functions as function pointers and attempts to load them I assume).



So, presumably, if a function is not supported, the function pointer returned when trying to load a GL function at runtime will be nullptr or some other value (not sure what platforms wouldnt return nullptr) that will cause your program to crash if you try to call it...


This also means, you can always do checks at runtime to ensure you have the correct opengl version available, and even individual functions. If youre using a lower opengl version, you can try loading some functions not available in your gl version as an extension as well (like if theres something specific you need from the higher version, but you cant ask for full support of that version for some reason)

#5266745 Vertex hashing

Posted by on 17 December 2015 - 12:04 AM

It seems to work fine for me when I pass in a pointer to an array of 3 floats.


It doesnt work if I make the function take an array (it just produces undeterministic garbage), but I dont at the moment see why (Is it taking the address of a pointer? Never really use arrays this way ph34r.png )


edit: yup, the "&" needs to go...

#5265789 MSAA help

Posted by on 10 December 2015 - 04:59 PM

Maybe you still need to do the second step (call glEnable( GL_MULTISAMPLE )), other than that, idk

#5265767 MSAA help

Posted by on 10 December 2015 - 02:45 PM

I think, for the default framebuffer, you tell the windowing system to give you MSAA, when you create the context.


Section 3.2 seems relevant for that purpose in the linked page (assuming you use raw windows API and not some library for creating window/context).

#5264752 Culling? Duplicate Impulses during Collision Resolution.

Posted by on 03 December 2015 - 11:10 AM

Once the first collision is processed, the box is now moving away from both A/B so the second collision would automatically be ignored.


Not sure how rotation would affect it...


'Proper' physics engines probably collect all contact points and only then solve for it.



No idea really I probably shouldnt have even posted ph34r.png

#5264584 PRNG Question

Posted by on 02 December 2015 - 08:47 AM

For each of your numbers, do you need a sequence of random numbers, or just a single random number (essentially hide the pattern in your initial set of numbers)?


For example in a game like minecraft, you might need to produce a random number given an x,y,z integer coordinate. For this, a hash function should produce a random-enough value, without needing to "warm up" a PRNG or whatever (since theyre designed to be random in a scenario like this, unlike prngs for which this would not be the primary use case)


Theres plenty to choose from, just search for an integer hash function.


If you do need a sequence of random numbers, hashing the seed first might produce better results than using sequential integers as seeds directly.

#5258551 Looking for feedback on menu system design

Posted by on 22 October 2015 - 12:54 PM

The menu buttons usually have shorter descriptors.


In your case something like:

-New game

-Load game (or 'Continue')

-Options (with both graphics/sound options there)



Is quicker to understand.


graphics/sound options should be grouped together because theyre both options, and could for example use a common 'apply changes' button or such. They might be 2 different tabs under the 'options' menu.


I suggest separating the 'quit' button from the rest. Spatial separation (add empty space or put it in some corner), color it red, put an empty line above it... That way you dont accidentally click it, and its easy to spot (if you want to quit, you dont use the other buttons, and vice versa).




Also, make sure the transition animations dont last longer than a fraction of a second. That kind of thing is annoying (might have just been the video though). For example, fade in the next menu WHILE the animation is playing, and allow making changes immediately (while the animation is still going)

#5258392 Problem with save mechanisms

Posted by on 21 October 2015 - 01:23 PM

Make sure you read and write the savefile in same order, or youll get garbage.

#5258078 Flow in an asymmetric game

Posted by on 20 October 2015 - 05:42 AM

Maybe you want some kind of stabilizing factor that is strong in early game and weakens toward the end.


Early, aggression will give you little benefit.


Late, aggression can gain momentum and swipe out entire alien empires.



Maybe you can even control it to shape the stability curve over time - maybe some games end up with early aggression, others with stability-aggression-stability, yet others with the stability-aggression progression.




-Tech development that gives you powerful attack weapons near the end (planet destroying lazors etc)

-Early tech that discourages heavy aggression (like nukes do today) but becomes less of a danger later (better defenses, maybe you capture so many planets they cant strike all, maybe population moved underground...)

-Finite resources with high cost to begin extraction, so early game you dont have need nor the resources to capture planets for their resources (too costly to begin extraction). But late game, you NEED the resources, and the enemy already build full extraction facilities (lots of money and time went into it)

-Make player unaware of enemy locations early on (information takes time to travel in space, poor 'radar' tech, etc), so you might find one or two planets of an enemy empire, but cant find the rest without going all over space.


Thats for stable-aggressive progression, but you get the other ones with little modifications (counter-counter weapons, access to new tech, multiple resources that shift importance in long term to affect gameplay...)

#5256532 What makes a City Builder fun?

Posted by on 10 October 2015 - 09:23 AM

It really depends on the player.


Some players focus primarily on visual appearance of the city, others just care about functionality, and yet others just go for whatever pops up in their mind and end up with some ugly design that doesnt even work - but at least it has that district where only dirt roads are allowed.


If you think about city builders, theres a bit of everything. Theyre sandboxes, the player can play just like they want to.


Create a complex simulation, but keep the rules lax enough that the player can decide what aspect they want to focus on. But make sure that it stays challenging IF that is what the player wants - for example let the player choose where to build their city (varying terrain, tourism, weather, trade opportunities, natural resources...)


You want a lot of variables like that. You dont want every city to be able to be everything at the same time. Thats boring. Theres little replay value in that. Give every city limited choices, and even more limited paths they can actually follow at once. Some more, some less (again, depends on player how much challenging restrictions they want).


Really, just throw in all the things and youve got a city builder.

#5256136 Empire wide buildings

Posted by on 07 October 2015 - 09:07 PM

Maybe something like internet services?


I mean, you would surely get +50% technology points if you set up stackoverflow or wikipedia :)

#5256005 Internal space ship gravity (Unity3d)

Posted by on 07 October 2015 - 07:59 AM

If I understand you correctly, your gravity works while ship is not rotating? So WHILE the ship rotates, theres issues, but when it stops, everything is ok?


If so, could the sliding be because the rotation causes the character to accelerate, so theres actually two forces, gravity and acceleration because of centrifugal pseudoforces (or whatever they call them)?


In that case, try:

1. Increase friction between floor and character - you cant slide if friction is high enough (assuming the physics work correctly and its not some glitch)

2. Dont accelerate the ship too fast (even angular acceleration is acceleration)

3. Design the ship to minimize such additional forces (dont make ship long on an axis where it rotates fast)

4. Separate the ship-internal physics completely from the external physics AKA cheat. Like if a player enters a ship, spawn them in a stationary "ship internals" world that has not much to do with the actual ship doing crazy 30 g manoeuvres while you chill there. How to accomplish this depends on your tools.


If this is a physics glitch instead of a natural consequence of rotating the ship too fast, then you might want to read on known issues with whatever you are using, or how they work, to figure out why its happening.

#5255778 Learning Calculus Online

Posted by on 06 October 2015 - 02:59 AM

I know from some graphics equations that that squiggly bar with a and b has something to do with angles or hemispheres, so I guess the sin()’s came from that.


If you mean the integral symbol, not just angles or hemispheres. You integrate over a variable, which might be an angle. In the article it just uses a generic "f(x)", where f is integrated over the variable x. A bit unclear, but here f(x) = sin(x), so thats where the sine comes. It could be any function, integrated over any variable (specified by the dx thing).




Then there is h.  What is this magical number?

"step size h"

Integrals are not discrete, you break it into steps of size h along the variable being integrated over to make it computable. You approximate the integral, h controls the accuracy. Infinitesimally small value (infinite steps) is equivalent to the integral itself.




Why is it divided by 3?

If you look inside the [] you can see that its something like 2*(sum of f(x) over half range) + 4*(sum of f(x) over half range) + the edges.

Ignoring edges, thats something like 6*(sum of f(x) over half range) = 3*(sum of f(x))

That 3 needs to go poof since we only want sum of f(x) over the range.


Thats a horrible simplification of what seems like a complicated method though. Stare at the derivation on the wikipedia page for a few hours to know why it actually is there smile.png



Integrals are not dependent with trigonometry in any fundamental way. You can integrate over trigonometric functions using the angle as the variable of integration, but thats no different from any other arbitrary function. That probably got you confused.


The rest seems to be just examples of using this approximation with more complicated functions (instead of sin(x)), spawning all those sqrts and stuff.



You can probably calculate the area of some discrete function using a for loop (sum of rectangular slices).

An integral is what you get with infinite steps, but you know that.

What the article shows, is not just boxes. A flat-top box is a bad approximation of a curved line. So they come up with maths to use different shapes for the top of the box. A slanted top instead of flat. Or maybe some fancy polynomial (which seems to be what this "simpsons rule" used in the article is?). To minimize the "error" between the flat top of the box, and the not-flat curve of the function being integrated.


I know khan academy is one place to learn such things, dont know if pace is right or if you like videos (get a book if not, should be plenty to choose from).

edit: https://www.khanacademy.org/math/integral-calculus/indefinite-definite-integrals  (Not sure if they cover the approximation used in that article, but it has something about approximation at least)

#5254818 Could this really be that slow?

Posted by on 30 September 2015 - 10:38 AM

If I calculated correctly, on 4 GHz core that would be like 4000 cycles for each cell. Given that for each cell you check a region of 9 cells (~500 cycles per checked cell), I guess thats feasible if theres some cache misses and branch mispredictions (googling tells me the former can be hundreds of cycles).


Are you running in release mode?


Is there a certain size of grid where performance suddenly falls? Maybe you can make a graph for fun smile.png