Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 28 May 2011
Offline Last Active Yesterday, 12:17 PM

#5184967 n-dimensional noise generation

Posted by Waterlimon on 04 October 2014 - 10:00 AM

You could also try to do it by setting the seed of the RNG. For example, you could use the hash function given by Alvaro to set the seed (the default_random_engine seems to have a method to set it)


Using something simple like x*width + y might work fine too. (you can combine this with another value which is the same for the entire map or texture, this would be the seed of your map/texture)


This means that after setting the seed, youll get the same exact sequence of numbers every time. This is useful if you need more than one random number per coordinate. So instead of a single random number that is the same every time, you can get as many as you want and theyll be the same every time.


Im not sure if this has performance implications or if it causes issues with the distribution of the random numbers generated.


Something like:

void genStuff(x,y)
    for 1 to 100
        float random=line(gen)
        *Do fancy generation logic using random*

#5184964 Should i prioritize CPU or Memory usage?

Posted by Waterlimon on 04 October 2014 - 09:47 AM

What you want is for your program to work as intended and not have any negative effects on the system.


Too high CPU/GPU use means it doesnt work. Too high memory use means it doesnt work.


But thats not all. You also need to take into account the context. If your program uses all of the RAM, it might work, but what if the user wants to run another program too? What if the user has a different amount of RAM than another user? What if the user doesnt want your program to constantly use the HDD because it wears it out or prevents the user from doing video capture or whatever? What if the user has a laptop and too much processing makes the battery run out fast or forms too much heat?


So for your map loading example, you want to make it adjustable. Youre probably not on a console, so every user and their machine is different. Thats why we have graphics options in practically all games (and a lot of them).


For the stuff that doesnt make sense to be adjustable, you need to predict what kind of resources the application will use and how much, and try to balance it all out so that nothing ends up being a huge issue.


Generally this is easy, since one of the approaches is usually easier than the others, so you can just use that one and come back to it later if required. If the approaches are vastly different in every aspect, it is more difficult since choosing the wrong one could be a complete waste of time (since you might need to reimplement the whole thing, not just make a small addition or tweak). For those situations you just need to have experience and know your projects requirements and make an educated guess.

#5184534 Funniest line of code ever ?

Posted by Waterlimon on 02 October 2014 - 04:12 AM

I would much prefer the use of arrays instead of separate variables for the animations, because there IS a mathematical relationship between them, and using separate variables hides that knowledge from the compiler.


ANIM* runAnims[4];

ANIM* idleAnims[4];


The same thing bugs me with many other things like vectors of all types, whatever they represent. If an array of variables isnt represented as an array or equivalent, theres bound to be repetition.


Though here something that mapped a direction vector to an animation would be nicer. But that is easy to implement by providing a unitDirectionToArrayIndex(vector<2> dir) helper function.

#5183720 Making a shot harder to pull off.

Posted by Waterlimon on 29 September 2014 - 07:06 AM

Do something funny like making the players weapon jam every time he is about to get a heartshot in a situation where you dont deem it acceptable.


Or change the game design on a larger scale to not make it such a problem.


Or add some random element to make it not successful most of the time (your arm is shaking and the gun is shaking all by itself and the bullet is shaking while flying because turbulence and the enemy is shaking while trying to avoid being hit and the heart is rapidly shifting position because adrenaline).

#5183702 ROBLOX/Other Games Programming(Lua)

Posted by Waterlimon on 29 September 2014 - 04:54 AM

Used to play roblox, now just use their forums as a tool of procrastination.




I actually came here to ask for some useful sites or tips to get me started. Yes I want to use Lua for more games, not just ROBLOX. I do have a semi good understanding of Lua, I just need some extra assistance. 


Ive seen many people go for the Lua based game engine LÖVE.


It seems to be limited to 2D, but has all the things a game engine should have (hardware accelerated sprite rendering with shaders, physics, threading, networking, bunch of utilities...)

It also seems possible to use LuaJIT (not sure if its enabled by default) so I guess it will also be faster than roblox for the Lua-side code.


So you could use that.



You should also learn at least the basics of some other language (probably C#, C++ or Java) simply because they are so popular and if you understand them, you will gain a better understanding of how any programming language (including Lua) works in general. For example you could just read through some C++ online tutorial to the point where you know what pointers are and make some silly console application.


Another thing that might be useful is to check the official Lua documentation. Especially the reference manual, since it seems to offer a good explanation of the workings of Lua (since as a dynamic scripting language there is some magic going on to map the Lua script to how the computer works at a low level).


And of course, keep googling and reading about things you want to do in whatever game you are working on, be it the general structure of your code, some GUI design issue or a difficult decision of how to implement jumping.


You still might find that you want to keep scripting in roblox because you get free hosting and a lot more publicity for your stuff than if you make an independent game (unless you are serious about it and are able to gather a community of your own around it).

#5181893 simple crafting system

Posted by Waterlimon on 21 September 2014 - 09:20 AM

I have always disliked crafting system where you supposedly have to discover a recipe to use it (=look it up on the wiki because theres no logic to the crafting ingredients required to make something)


So I personally would prefer a very transparent crafting system. Basically an ingame list of all craftable items, structured logically. And highlight items you might want to craft (relevant to current situation), AND items you can craft or almost can craft (you have the ingredients in inventory).

#5181767 Point based physics engine

Posted by Waterlimon on 20 September 2014 - 02:18 PM

Ok I see, so you want basically a grid based (3D) game with physics?


What I was thinking is that give each 'point' a float position to make the physics smooth.


However, you could still have the physics rely on the grid cells - a point may only interact with neighboring grid cells.



I did something similar for a 2D grid game, because I wanted the player to be able to stand anywhere, not just at the center of a grid cell. But the collision detection still worked based on grid cells (the player was 1 grid cell sized square)



What I did was to have a normal grid for the world (you know, grass in this cell, stone here etc.)

And each moving entity had:

-Float position, velocity

-Integer position (grid position)

And the physics applied velocity to the float position, which was rounded to get the grid position (so it can find neighbor cells to do collision detection, like if in a cell above ground, limit the float position from going too low into the ground).

#5181753 Point based physics engine

Posted by Waterlimon on 20 September 2014 - 12:58 PM

Were you perhaps thinking of simulating it more like fluid physics, where the points interact with each other through forces based on distance? Like atoms and other realistic thingys.


Since that would give them such an 'extent' (although blurry) of sorts.


If all the points had a limited radius of influence, you could use a hash map or a grid to do the physics in O(N) (since for each point, you only have a fixed number of surrounding grid cells to check, and only a very limited number of other points can fit in those cells) I think... :|


It would be almost equal to having integer coords and only interacting with points in adjacent coords. Just a bit more detail.

#5177172 Collision detection against curves or other complex shapes and bitmaps.

Posted by Waterlimon on 31 August 2014 - 04:07 AM

You would either represent it as a collection of simple collision primitives (circles, boxes etc.) that are scaled and rotated to approximate it well, or you would approximate it as an arbitrary polygon (which the physics engine could triangulate or just do physics based on the polygon edges or whatever works the best)


Check some 2D physics engine and see what features it has.

#5175848 MMO Gap issue

Posted by Waterlimon on 24 August 2014 - 12:14 PM

Progress is measured by how close you get to a goal (which may be infinitely far away but whatever)


Change the goal over time so newcomers will not be pursuing the same goal as the veterans.


This can be implemented as starting a new world every once in a while (or expanding the world and putting new players in the new regions), but you could come up with something that works in a single world/place. Like a new branch of magic to pursue that is slightly better than the old one when people start getting too good at the old one.


It might make the game remain interesting for longer for the older players too as they have to keep 'adapting'. Or it might just annoy them when their work becomes less and less worthy if they cling to it.

#5173327 Is it possible that I just simply lack the required intelligence?

Posted by Waterlimon on 13 August 2014 - 07:07 AM

Also, when you find mistakes in your code, think if theres anything you can change in the way you code stuff to avoid similar mistakes in the future.
The whole point of many language features and coding practises is to prevention bugs and keep everything simple, so focus on that.

#5169512 What happened to Rastertek?

Posted by Waterlimon on 27 July 2014 - 09:29 AM



seems to have the tutorials there, dont know if you can download the files though.

#5168563 Rotating camera with mouse

Posted by Waterlimon on 22 July 2014 - 10:00 PM

m_horizontalAngle+= mouseSpeed*float(width/2-dx);

Since you are adding to the angle, you should be adding 0 when the mouse doesnt move. However, if the mouse doesnt move (dx=dy=0), you end up adding mouseSpeed*float(width/2) horizontally and same for vertical.


If you want to move the camera when the mouse moves, remove the width/2 and height/2 parts and it might work like you intended it to.


If you want to move the camera whenever the mouse is not at the center of the screen, pass in the mouse position relative to the center of the screen (mouse.x-width/2, mouse.y-height/2) instead of the delta position.

#5168004 [Depth buffer] From linear -> non-linear depth values

Posted by Waterlimon on 20 July 2014 - 02:58 PM

You should be able to just do the inverse operations in the exact reverse order to do that (+ becomes -, / becomes * and apply operations in reverse order)

#5167408 2D rotated rectangle collision detection

Posted by Waterlimon on 17 July 2014 - 08:50 AM

I think the tool to use here is the Separating Axis Theorem (SAT). If there is a plane/line that separates two objects, they dont intersect.


Basically, you would take all the planes (/lines) that bound your rectangle (based on the faces of the rectangle),


Then, for each of those, you check if the other box is completely on the 'outside' side of the plane (you can do this by checking each vertex separately).


If the above is true for even a single plane/line, there is no intersection.



This works for any convex shape. It wont get you the point of intersection though, but you didnt need that. Google for an optimal way to implement it, the above was just a vague description of how it works (might not even be exactly correct).