Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 Jul 2003
Offline Last Active Oct 14 2016 12:47 PM

#5310972 Simplifying Lua-Scripting for Users

Posted by on 15 September 2016 - 02:06 PM

You might want to take a look at how Urho3D does it. They implement Lua scripts as a component that you can add to an object. You can register to receive particular events in script, and the events are handed off to the proper event handlers in the script object.
Urho3D serialization serializes to XML rather than a Lua table, however, but you still might be able to get some ideas by seeing how they do things. In my own code that uses Urho3D, I have written routines that can save/load objects to/from Lua tables. It's not too difficult.

#5309458 Weird 'attempt to index' Lua Error

Posted by on 04 September 2016 - 08:03 PM

Are you running it in your own application that has Lua embedded by any chance? If so, are you being sure to call luaL_openlibs() to open the standard libraries?

#5308530 the dreaded "escort" quest

Posted by on 29 August 2016 - 01:09 PM

An early prototype of goblinson crusoe was "Goblin Wizard: The Escort Quest". In fact, my original vision for GC was as a game centered fully around escort quests. GC was to be an apprentice wizard whose master is suffering from rapidly advancing dementia, charging from adventure to adventure while his hapless student frantically tries to keep him out of danger.

Something I have noticed about escort quests as a result of this experiment is that, in the context of a different game they kinda suck. If I'm raiding a bandit camp, thrashing dudes and looting corpses, then I spring a captive from a cage and have to follow her at snail's pace through a string of scripted ambushes, it's a change of context that is actually kinda painful. But I don't think that really speaks to the escort quest itself being bad, just the juxtaposition of a slower-paced string of ambushes against the gore-splattered free-for-all that preceded it. It's jarring.

What I found in that early prototype of GC is that when approached with the right assumptions and frame of mind, an escort quest (even one of the traditionally 'bad' ones like a slow walker) isn't as bad as you might think. Certainly, my test audience (consisting of friends and family) found it enjoyable. The things such as slow pace and tendency to careen crazily into obvious ambushes were part of the core gameplay rather than a distraction from the core gameplay.

#5306465 Perlin Noise - seamless cube maps

Posted by on 17 August 2016 - 08:48 PM

Your code isn't doing exactly what you expect it to. You'd probably get better results if you divide x and y by dim before you subtract the centroid.

Any box in 3D space is going to map from the coords (x1,y1,z1) to (x2,y2,z2). The mapping ranges for each of the faces will derive from these extents. For example, the back face will map from (x1,y1,z2) to (x2,y2,z2) while the right face will map from (x2,y1,z1) to (x2,y2,z2). And thus, the back and the right faces will share an edge, delineated by the line segment from (x2,y1,z2) to (x2,y2,z2). So, say you have a cube of dim=512. You want to center it at 0, so your cube extents would be (-256,-256,-256) to (256,256,256). However, in your case (assuming image dim=512) you would be mapping from (0,0,1) to (512,512,1) on the back face (before the centroid is subtracted). But the right face maps from (1,0,0) to (1,512,512). The back and right faces in this case don't share an edge.

So you could either divide x and y by dim before subtracting the centroid, so that your cube extents become (0,0,0)->(1,1,1), or you could use dim for the extents so that your cube becomes (0,0,0)->(dim,dim,dim). It doesn't really matter, since you simply normalize the coordinates to unit length.

#5304126 Pseudo 3D And Eye Of The Beholder Or Bard's Tale

Posted by on 05 August 2016 - 01:11 AM

Just go 3D. In this day and age, "keeping it simple" involves using modern hardware, api and engine capabilities, rather than revisiting old hacks that were originally intended to circumvent hardware limitations. You can use modern 3d apis and still mimic the old visual style.

#5299914 Linux for game development

Posted by on 09 July 2016 - 04:54 PM

I recommend you grab a Live CD or USB boot of some different distros to find one you like. I'm currently using Linux Mint with the Cinnamon desktop, but in the past I've used many other different distros. Although it's easy to get confused, given the number of different distros available, it's helpful to remember that many of them work the same way. Anything based on Debian, for example (Ubuntu, Mint, etc...) is going to be centered around the same basic tools for package management, as is anything based on Red Hat. You've got a few different choices for the actual presentation of the desktop, such as Gnome, KDE, Cinnamon, etc... But ultimately, they all basically work the same.

I'd second Bregma's advice for Fedora, Ubuntu or Mint, with a slight personal preferential lean toward Ubuntu and Mint rather than Fedora. You can read about creating a live bootable USB for Ubuntu at http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-ubuntu and a live USB for Mint at https://community.linuxmint.com/tutorial/view/744

#5298493 Help me (learn to) develop open environments

Posted by on 28 June 2016 - 11:34 PM

This is where having the proper tools can help immensely. Creating a natural environment purely by hand can be somewhat difficult. You can ease your task immensely by incorporating procedural methods into your pipeline. Procedural methods can provide a way to quickly fill in natural detail, giving you a base to work from, after which you use other editing tools to tweak the environment.

You didn't say what your development environment and/or engine was going to be. Typically, the engine will provide some sort of Terrain component to be used in-game, and that component will typically make use of a heightmap texture, or an image that represents elevation to be applied to the subdivided plane of the world. For example, if you are using Unity, the Unity engine provides a Terrain object that uses a heightmap, and an editor to create a heightmap.

If your terrain editing tool provides access to fractal noise methods, you can use those to create a terrain base. Then you can use brushes for height editing, smoothing, terrain painting, etc... in order to further refine the heightmap. The finished heightmap can be saved as an image file, and imported by the engine for use in the game world.

As far as adding things like forests, paths, rivers and so forth, then again you can be helped immensely by having the right tools. Forests can be added using procedural methods such as fractal scattering. A noise fractal is created that delineates continuous areas, and when combined with a slope or steepness map of the terrain (ie, a layer that indicates how steep the corresponding terrain is, in order to exclude trees from spawning on steep slopes) can be used to determine the probability of a tree spawning in a given location, and populate the map correspondingly.

For rivers and paths, it can be helpful to have access to some sort of spline tool. For an example of this, here are some shots of my own work-in-progress terrain editor:


The spline tool operates by allowing the user to set a series of waypoints, which are connected together using a spline curve. Then a filter is applied to the spline to perform a function such as, in this case, smoothing a road and painting the road with a different terrain. A similar filter is used to create river beds that carve through the terrain.

#5296154 Isometric hack and slash, from scratch

Posted by on 11 June 2016 - 07:16 PM

What is your previous experience? Those kinds of games aren't as easy as you suggest, and your success will be highly dependent on your skill level.

Given your statement about being a beginner, you've got your work cut out for you. It's likely that some people will advise you to start simpler, with Pong or something. To that I say, "pshaw." Go ahead and work on your isometric h&s.

In this day and age, there isn't much to differentiate between an isometric and other types of games. Even assuming a true orthographic projection, you still will likely use many of the same tools as you would for any number of other styles. Inity, unreal, cryengine, etc are all suitable, as are open source engines such as urho3d.

There are many questions to ask yourself. Orthographic projection (such as original diablo) or perspective third person (diablo 3, path of exile)? Tile based or freeform? Randomly generated levels or static prebuilt? Traditionally animated 2d sprite character or fully rigged 3d character models? (from personal experience, rigged 3d models are significantly preferable if you plan to do paper-doling of equipment.)

Your answers to these questions will inform your decision making. If you go a full traditional 2d route, you will want to choose an engine or a set of libraries to facilitate that. Even in 2d, you will want a framework with strong shader support, since you're probably going to want to do things that shader make simple, such as elemental halo effects.

I have written a bit about various aspects of isometric game creation in my journal (link in my sig) if you are interested in reading some stuff. As well, feel free to pm me directly if you wish. I'm always happy to help.

#5293719 Do you usually prefix your classes with the letter 'C' or something e...

Posted by on 26 May 2016 - 10:46 PM

I still use the C prefix. Did it for many years, and I have other things to worry about than trying to change harmless old habits like that.

#5293150 How do I create tileable 3D Perlin/Simplex noise?

Posted by on 23 May 2016 - 11:37 PM

Think I may have found a quick (not 100% correct) fix for the lines in the simplex noise. If you are using the latest code from the repo at Github (link in signature), then the fix has been pushed. If you are using older code (and your earlier link to sourceforge leads me to believe that such is the case) then you'll have to make the fix yourself. The fix is: open the noise_gen.cpp file. Find the function simplex_noise6D. Scroll through the function until you find the line that reads n+=gr*t*t*t*t; (it'll be around line 1224) and change it to n+=gr*t*t*t*t*t; Rebuild, and it should be a bit better. It seems to be better in my personal tests at least:


If you still get lines, add another *t to the expression.

The lines occur because the weights for the simplex corners are being overscaled. While adding a couple points to the exponent of gr*t^4 scales the weight smaller to help correct that, it also alters the overall character of the result. It'll look a lot less sharp the higher you go.

#5293110 How do I create tileable 3D Perlin/Simplex noise?

Posted by on 23 May 2016 - 02:41 PM

The issue with the lines is a problem inherent to the calculation of the weighting factors in the 6d implementation of simplex noise. It's been several years now, so I can no longer remember the exact details of why I was unable to find weight factors that would work correctly, but the ultimate conclusion I came to was that using standard perlin noise gave much better results than simplex at higher dimensions.

Standard noise is, for me at least, easier to extend. Simplex noise is simple enough conceptually, but the implementation gets very weird in a hurry as you add dimensions. I based my simplex generator on a python n_dimensional generator I found somewhere. The python generator exhibited the same anomalous behavior.

I would say to give standard noise a try to see if results work better for you. Meantime, I might dig back into things to see if I can work out the underlying problem this time around.

#5291721 Scripting

Posted by on 15 May 2016 - 01:31 PM

...mostly for learning purposes

...I'm looking for a way to make it easy for the end-user to create and manipulate entities.

The second one can be quite complicated. In light of the first, it might be a better idea for you to start learning the basics of integrating a scripting language, as well as all the other things you need to learn. With experience, you might gain some useful insight into the latter one.

The actual integration of a scripting language can be complex. The highest level is a straight-across, 1 for 1 binding of your API. Somebody (I think it was Hodgman) once linked a colorful article about why that might not be the best idea, but I didn't save the link. The gist of it, though, is that languages like Lua are different beasts than C++, and if all you're going to do is a 1 for 1 API binding, you're probably better off just using C++.

To go beyond 1 for 1 binding, though, takes a little bit of engine-specific ingenuity. One engine, I use, Urho3D, implements Lua and AngelScript binding using the 1 for 1 API exposure, but they also integrate a ScriptObject component that can be added to an object. This component acts as a glue layer, passing events across the Lua/C++ or AS/C++ boundary.

Still, I suggest you spend some time playing with things, rather than trying to design something easy to use by end-users right out of the gate.

#5291651 really slow software rendering on android with SDL2

Posted by on 14 May 2016 - 09:15 PM

I just want to know the reason why on my desktop the game runs at 50fps and the same exact code runs at 18fps on the S4.

Because comparing a desktop processor side-by-side with a mobile processor using clock frequency alone is pointless. There are a lot more complicated features of a given processor that go into its overall performance. Mobile processors are very much designed with power efficiency and low heat generation in mind. They have to be, in order for the battery to last more than 30 seconds and in order for the heat output to not burn a hole in your hand.

The desktop processor cares MUCH less about power efficiency and heat dissipation, given its mains power source and the presence of on-board heatsink and cooling fans.

The way I heard it once is that clock frequency is a lot like engine RPM. Even if a 2-cycle weed eater and a turbo-charged Chevy big block 454 are pulling the same number of RPMs, that doesn't mean they're putting out the same amount of horsepower.

#5290979 Distributing a variable [0-1] logarithmically

Posted by on 10 May 2016 - 09:50 AM

In the book Texturing and Modeling: A Procedural Approach, one of the authors (I believe it was Perlin) provided two functions he uses to re-distribute values in the unit range:

function bias(t, b) return math.pow(t, math.log(b)/math.log(0.5)) end
function gain(t, g) if t<0.5 then return bias(1.0-g, 2.0*t)/2.0 else return 1.0-bias(1.0-g, 2.0-2.0*t)/2.0 end end
The bias function is used to push values toward one end or the other; values of b less than 0.5 push values of t nearer to 0, while a bias greater than 0.5 push the values toward 1. gain uses bias, and has the effect that if g is less than 0.5, the values are pushed toward the ends, while greater than 0.5 values are pushed toward the middle. In both these functions, 0.5 for the bias or gain factor results in the linear curve. For example:

If the linear curve looks like this:


then the same curve with bias(0.2) applies looks like this:


bias(0.8) looks like:


gain(0.2) looks like:


and gain(0.8) looks like:


In all cases, if t is in the range 0,1 then the output will also be in the range 0,1.

#5290196 How do I create tileable 3D Perlin/Simplex noise?

Posted by on 04 May 2016 - 09:49 PM

Some years back, when I was implementing my own higher orders of simplex, I found an implementation of N-dimensional simplex noise in Python: https://github.com/Craig-Macomber/N-dimensional-simplex-noise/blob/master/simplex.py Converting it from Python would take a little bit of work, but you could probably work it out in time.

You might be able to find more by googling for "n dimensional simplex noise". The simplest variant to convert to higher dimensions is the original Perlin noise, as it simply deals with interpolating the corners of an N-dimensional hypercube. Conceptually it's simple, but algorithmically it gets complex in an exponential fashion. You can decompose the recursive structure of standard Perlin noise into polynomial form, but the higher orders get pretty sticky. I talk about my efforts to write polynomial versions of 6D noise at http://www.gamedev.net/blog/33/entry-2254250-derivative-noise/

The code posted by vinterberg demonstrates the blending method which is the simplest method, mathematically. For basic cloud noise, it's probably suitable. However, for high-contrast functions, or functions with strongly defined patterns, it might result in blending artifacts, as this image shows:


The variant on the left uses the blending scheme. 4 areas of 2D cellular noise are generated, then blended together to create the seamless pattern. At the edges, the pattern achieves a clarity that the center lacks, due to the center being a near-equal blend of 4 different noise sets, while the edges are more strongly weighted toward one of the 4 areas. Expanded out across a grid, the pattern becomes unmistakeable:


The one on the right uses 4 dimensional noise and the clifford torus mapping to generate the seamless pattern, and while the curvature of the domain space is apparent in the curvy distortion of the shapes (in standard 2D cellular noise, these shapes are convex polygons with straight edges) the overall contrast of the pattern is preserved throughout the image, as is apparent when the image is tiled: