Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Force Quilt
Jan 28, 2006

Shinx posted:

What is the general idea with regards to learning programming for gaming? Should I take CS at a college/university or should I just self-teach a programming language?

Just a note that computer science is to programming as biology is to dressing wounds.

Adbot
ADBOT LOVES YOU

Pfhreak
Jan 30, 2004

Frog Blast The Vent Core!

Force Quilt posted:

Just a note that computer science is to programming as biology is to dressing wounds.

That's not entirely fair. While that might arguably be fair for Comp Sci as a discipline, it's certainly not the case for a Comp Sci degree. Most CS degrees do teach programming and software engineering in addition to the academic stuff.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Suspicious Dish posted:

Flash is the best vector art modeller I've used. Once you get used to it and the "cookie cutter" effect, it feels more like manipulating clay than dealing with Bezier curves. Besides that, Photoshop is the known standard and works tremendously well.
Paint.NET is an adequate substitute for Photoshop though, if you'd rather stay inexpensive and legal.

The real answer for a 2D spriting tool, when I asked about ten pages back, is "a lot of practice and, even when you have a lot of practice, still a lot of time." There's no tool that makes it fast and easy. Just in case you were hoping for a magic bullet like I was.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
I've been working on a Zelda-like dungeon adventure game for my Forth VM, and I wanted to show off the scripting system. Here we have a room containing an empty chest. If the player fills it with gold, the chest will disappear and monsters will spawn, locking the doors until all enemies have been defeated. When we visit the room later, the chest will stay gone and no enemies will spawn.





Here's the setup routine for that room:
code:
:var fissure-gold
:var fissure-doors
: r1-3

	fissure-doors 3 120 43 spawn-door
	fissure-doors 1 158 43 spawn-door
	
	{ ' is-scorpion? count 1 < fissure-doors ! } spawn-daemon

	fissure-gold @ -if
		{
			10 take-gold -if exit then
			true fissure-gold !
			dialog[ "You place the gold in the chest." ]-text
			destroy-chest
			126 43 spawn-scorpion
			152 43 spawn-scorpion
		} 139 43 spawn-chest
	then
;
Curly braces are used for defining inline routines, which can be provided as arguments to objects when they're created- in this case we use one for spawn-daemon and another to set up a script for when the chest is activated. spawn-daemon sets up a script which will run every game tick, in this case checking the number of scorpions and updating the global used to control the doors.

I really like working with Forth because it scratches my "low-level coding" itch and is equally suitable for writing game engines or building up these sorts of high-level abstractions. What kinds of approaches do you folks typically use for wiring up this sort of one-off logic, aside from Lua?

Internet Janitor fucked around with this message at 00:04 on Jan 8, 2012

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Internet Janitor posted:

What kinds of approaches do you folks typically use for wiring up this sort of one-off logic, aside from Lua?
These days, I'm a fan of visual scripting languages with discreet functional elements that can be rewired. The back-end could be any number of things, but at this point I'm kind of leery of handing designers a raw scripting system.

... but, we also tend to use UDK or Unity (and for the next Unity game - I'm insisting on uScript), so that does pattern our behaviors a bit. If I had to write an engine from bare metal and didn't have time for a visual system, I'd typically just stop at Lua and cross my fingers.

Your Computer
Oct 3, 2008




Grimey Drawer

Internet Janitor posted:



I'd love to see you write more on Forth (wasn't there a thread somewhere?). To me, having learned programming through Java, Forth is like reading an alien language; Completely impossible, yet intriguing!
With the VM and now this, your approach to Forth is looking really interesting to me. I've dabbled in assembly so I can understand that "low-level coding" itch!

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Your Computer: thanks! I started a thread about half a year ago when I was first getting into the language, but there was never much interest. I don't usually get a lot of feedback when I post my code here so I assumed it wasn't all that intriguing. I'll definitely be putting my adventure game on github when I've worked out a few bugs and made more progress on level design. In the meantime all my existing code for the VM project is available:

The MakoVM repository
A Crash Course in Mako and my Forth dialect

If you're interested in pure CS wankery here's an extremely simple garbage collector and a set of Lisp-style cons-pair list manipulation operations, all in Forth: Pair.fs
code:
: list-join ( first* second* -- pair* )
	over nil? if swap drop exit then
	>r split r> list-join pair
;

: list-nth ( pair* n -- value )
	over nil? if "bad list index!" typeln halt then
	dup -if drop first exit then
	1 - swap rest swap list-nth
;

Internet Janitor fucked around with this message at 06:23 on Jan 8, 2012

redleader
Aug 18, 2005

Engage according to operational parameters

Internet Janitor posted:

Your Computer: thanks! I started a thread about half a year ago when I was first getting into the language, but there was never much interest. I don't usually get a lot of feedback when I post my code here so I assumed it wasn't all that intriguing.

For what it's worth, I enjoy seeing your posts in this forum. You're getting a lot of mileage from your project, and it's neat seeing your completed games. I just don't comment because Forth is totally outside my understanding and I don't really have anything useful to say :shobon:

Force Quilt
Jan 28, 2006

Pfhreak posted:

That's not entirely fair. While that might arguably be fair for Comp Sci as a discipline, it's certainly not the case for a Comp Sci degree. Most CS degrees do teach programming and software engineering in addition to the academic stuff.

I agree. IMHO it's better to learn to program than learn a programming language. My point is that if one wants to learn to program, it's a good idea to just start programming, school or not. Theory isn't much use without practice, and IMHO too much theory leads to bad programmers who are more concerned with correctness and paradigms and adhering to dogmas than actually getting stuff done, and as an indie developer, getting stuff done is more important than doing it right. (Though doing it right is also important, it's just not as important.)

dizzywhip
Dec 23, 2005

Internet Janitor posted:

Here's the setup routine for that room:
code:
:var fissure-gold
:var fissure-doors
: r1-3

	fissure-doors 3 120 43 spawn-door
	fissure-doors 1 158 43 spawn-door
	
	{ ' is-scorpion? count 1 < fissure-doors ! } spawn-daemon

	fissure-gold @ -if
		{
			10 take-gold -if exit then
			true fissure-gold !
			dialog[ "You place the gold in the chest." ]-text
			destroy-chest
			126 43 spawn-scorpion
			152 43 spawn-scorpion
		} 139 43 spawn-chest
	then
;

:stonk:

This looks like a random permutation of the tokens of a normal program.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Forth is postfix?

edit: Here's some C-like code that expresses basically the same thing as that script:
code:
bool fissureGold;
bool fissureDoors;

void daemonCode() {
	if (count(isScorpion) < 1) { fissureDoors = false; }
}

void chestCode(int id) {
	if (!takeGold(10)) { return; }
	fissureGold = true;
	textDialog("You place the gold in the chest.");
	destroyChest(id);
	spawnScorpion(126, 43);
	spawnScorpion(152, 43);
}

void room() {
	spawnDoor(left,  120, 43, &fissureGold);
	spawnDoor(right, 158, 43, &fissureGold);

	spawnDaemon(daemonCode);
	
	if (!fissureGold) {
		spawnChest(chestCode, 139, 43);
	}
}

Internet Janitor fucked around with this message at 02:25 on Jan 9, 2012

dizzywhip
Dec 23, 2005

I'm sure it makes perfect sense if you know the language, I've just never seen anything like it before.

chunkles
Aug 14, 2005

i am completely immersed in darkness
as i turn my body away from the sun
Forth is cool, keep posting about it. Also highly recommended: Factor.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
I'm a huge fan of what Blizzard did in WC3 and SC2 where they had a graphical editor that was ultimately capable of laying down most of the scripting facilities through the editor GUI. Stuff like that has been generally easy for non-programmers to pick up.

Ultimately though, being able to do something like that consumes a lot of time, and if you don't have the programming resources available, then you're probably better off using a scripting language. Lua has a major advantage in that you can easily feed it code bits to run to force things to happen in the world or debug.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

redleader posted:

For what it's worth, I enjoy seeing your posts in this forum. You're getting a lot of mileage from your project, and it's neat seeing your completed games. I just don't comment because Forth is totally outside my understanding and I don't really have anything useful to say :shobon:

Seconding this - your stuff is cool as heck Internet Janitor and I hope you don't take people's occasional relative silence to indicate a lack of interest. Forth is just so unlike the C/C++/C#/Java type languages many of us are familiar with that it's hard to come up with any kind of intelligent comments or questions.

Mostly I just go all :stare: that you managed to not only write your own VM, but you pushed it to the point that you can write graphics-based games in it. Goddamn dude, nice work.

duck monster
Dec 15, 2004

Gordon Cole posted:

I'm sure it makes perfect sense if you know the language, I've just never seen anything like it before.

Forth is like if someone invented the most simplest , powerful and logically coherent verbal language ever, but it was so different to the way normal humans spoke that if you heard it, it sounded like TV white noise.

Forth in a sentence: Everything is stacks, you put things on a stack then you do something to the stack and put the result on the stack.

Thats it, forth explained. I should also add, that its ridiculously meta-programming-ish. Out of the box it doesn't even understand variables, you need to teach it the concept of variables, usually with a line of code. But then you can add all sorts of constructs to it like Object oritentation and it becomes more and more powerful and expressive as it goes on. And you name it, you can implement the fucker in forth.Te end result is that its the ultimate toaster-coding language, it can be assembly-language close to the metal, but you can implement some serioualy high leve l constructs in it.

I remember in the 90s being utterly mystified why Unix was implemented in C rather than forth. I guess lisp guys wondered the same (although unlike lisp, forth can be extremely fast, not that it really matters with modern lisp compiler design, but it sure did used to matter!)

The details are a bit more complex, but like lisp its all about taking a loving simple concept and using that concept to expand into something rich and powerful.

Also Forth is one of the simplest languages on the planet to write a compiler for, because its such an inherently simple language. My first forth compiler was about 10 pages of qbasic, that compiled it to Z80 code, sometime in the 90s.

Someone who is not me should do a 'Lets teach ourselves forth" thread. Its a language that when the penny drops as to how to "think" in forth, it'll cause you to look at the way you think about code in a totally new way, and your hair will blow back just a little bit.

"Its like Everything is reverse polish now, like out there is the true world, and in here is the dream". Forth won't let you gently caress a giant blue chick though.

duck monster fucked around with this message at 12:20 on Jan 9, 2012

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
And additionally, everybody should play around with a stack-based VM one of these days and write some code in it. Decompile some .NET code to CIL and look at the assembly dump and understand it.

After a while you can just write algorithms in bytecode and compile code in your head. (OK, that link is ActionScript Byte Code, not CIL, but they're quite similar)

TJChap2840
Sep 24, 2009

Suspicious Dish posted:

And additionally, everybody should play around with a stack-based VM one of these days and write some code in it. Decompile some .NET code to CIL and look at the assembly dump and understand it.

After a while you can just write algorithms in bytecode and compile code in your head. (OK, that link is ActionScript Byte Code, not CIL, but they're quite similar)

I'd like to know more about this. Where can I go for more information?

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
If this is plug-your-VM day then okay, I'm working on what is basically a C# ripoff combination resource manager/runtime focused on serialization, predictable execution, and speed. It has some weird quirks.

Basically I'm trying to get most of the advantages of how Unreal handles data without the disadvantage of UnrealScript being kind of hosed up, and being fast enough to handle important stuff like rendering code. It was expanded to have silly stuff like native code compilation and thread serialization, which are ironically not mutually exclusive. The VM has 33 opcodes and otherwise makes extreme abuse of intrinsics.

It's not quite ready for public consumption yet, but it is being used in my current project's tools!

OneEightHundred fucked around with this message at 00:54 on Jan 10, 2012

Unormal
Nov 16, 2004

Mod sass? This evening?! But the cakes aren't ready! THE CAKES!
Fun Shoe
Heh, little tidbit for C# component-composition-based engine. I'm learning Unity3d and it taught me that:

public T GetComponent<T>() where T : IPart

is a heck of a lot cleaner in practice than

public IPart GetComponent( string Name )

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

TJChap2840 posted:

I'd like to know more about this. Where can I go for more information?

What do you want to understand? For C#, ildasm is the standard disassembler. If you're not on Windows, use monodis there. I'm more familiar with the ActionScript Byte Code (ABC) used by Flash, so let's compile a simple function to that:

code:
function foo() {
  var o = 1;
  print(o.toString());
}
Taking this, I compiled it in my head to:

code:
function foo() {
  getlocal0
  pushscope // NOTE: This is the standard prologue of any function in ABC.

  pushbyte 1
  setlocal1 // NOTE: I'm allocating "o" to local 1.
  findpropstrict ::print // NOTE: There's a whole system called 'multinames' that I'm glossing over here.
  getlocal1
  callproperty ::toString 0 // NOTE: The '0' is the number of arguments to the function.
  callproperty ::print 1
}
Let's go over the VM state at each bytecode, ignoring the prologue:

{} is the stack, [] is the locals.

code:
{} []
  pushbyte 1
{ 1 } []
  setlocal1 // NOTE: I'm allocating "o" to local 1.
{} [ 1 ]
  findpropstrict ::print // findpropstrict searches a bunch of things to find the property you're looking for, then pushes the *owner* of the property onto the stack. In this case, the global object owns the "print" function, so...
{ global } [ 1 ]
  getlocal1
{ global 1 } [ 1 ]
  callproperty ::toString 0 // callproperty takes the receiver object, which is 1, and 0 arguments off of the stack, and pushes the result of the function back on to the stack.
{ global "1" } [ 1 ]
  callproperty ::print 1
{} [ 1 ]

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Unormal posted:

Heh, little tidbit for C# component-composition-based engine. I'm learning Unity3d and it taught me that:

public T GetComponent<T>() where T : IPart

is a heck of a lot cleaner in practice than

public IPart GetComponent( string Name )

I've been running my rear end into the ground doing the messy way, basically because I want to be able to smash away at a lot of the game coding in Python itself. So I can't rely on static types at all. Otherwise templates--or at least generics as done here--makes a lot more sense.

duck monster
Dec 15, 2004

loving unity.

I've been coding away at an OcTree boxely voxely type thing , mainly because it seems like an interesting thing to do, and I decided to use Boo because it looks a bit like python, and python is cool yeah.

gently caress!

Boo is Mostly like python except it really loving isn't, its sort of C# with crazy rear end syntactic sugar and duck typing usually but not always.

The probelem is, boo is just poorly documented. The boo language has very poor documentation, and theres even less about how to use it in Unity, although I've pretty much been able to infer that part from reading the C#. I spent half a day banging my head on the wall trying to figure out how to pass arrays to a loving function. Something so god drat basic , but yet its not documented anywhere.

Turns out its just def blah (something as (type)):

right cool. Next cab off the rank. Appending to an array. *digs through manual* Oh :smith:

This loving thing. Unity you cunts, just give us ironpython for gently caress sake.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
I know next to nothing about Unity but from the one or two times I've bothered poke around at it I remember seeing warnings against using Boo. The explanation is that (a) it's not really Python and the small differences will drive Python people nuts, and (b) it's not supported on some platforms (iOS?).

But hey, since you're working on a boxely voxely type thing let me ask you this - does Unity support direct creation and manipulation of vertex/index arrays? Can you give the engine a list of vertex/index data and a custom shader and tell it to go draw the mesh? If not, what are you using to draw your voxels?


e: Can anyone recommend a book on Unity development that is written for programmers? Judging by some of the Amazon preview pages it looks like many of the books out there are written for Idea Guys and don't actually go into much depth on the technical/scripting discussions.

PDP-1 fucked around with this message at 19:24 on Jan 10, 2012

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?
I always have this problem when I touch Unity shaders...

Can anyone think of why this wouldn't properly set the tint on all associated sprites?

code:
// Tints all children, children's children, etc AND this object
function TintRecursively(gameObj : GameObject, color : Color)
{
	var meshRenderers = this.gameObject.GetComponentsInChildren(MeshRenderer);
	for (var meshRenderer : MeshRenderer in meshRenderers)
	{
		meshRenderer.material.SetColor("_Color", color);
	}
}
I know it's hitting every single object in the hierarchy, but no color change occurs. If I manually change the tint color on the material in my assets view (pre-execution), it works fine, so the shader itself is properly taking the tint value. I'm just not having any luck changing it run-time.

I use a variant of the above code to fade a screen-sized polygon out as well, and that works fine, so... weird. Ideas are welcome. I think I might be running afoul of the "materials" vs "material" difference, where changing values on the "materials" member never seemed to work in the past, but maybe now I have to, or... bluh. This part of Unity is documented incredibly poorly.


Bonus question: what is the variable type on var meshRenderers, as expressed in JavaScript? I know how it would look in C#, but I've never gotten an equivalent var type in JScript that works (and I hate leaving it dynamically typed).

Shalinor fucked around with this message at 19:26 on Jan 10, 2012

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

PDP-1 posted:

But hey, since you're working on a boxely voxely type thing let me ask you this - does Unity support direct creation and manipulation of vertex/index arrays? Can you give the engine a list of vertex/index data and a custom shader and tell it to go draw the mesh? If not, what are you using to draw your voxels?
You can certainly make your own vertex/index arrays, in a 'Mesh' or 'SharedMesh' object, because I have a function doing that, and you can do custom shaders. You don't so much "tell it to go draw the mesh" as attach the mesh to an object that has a mesh renderer though.

But I think Unity is probably not great for voxeling, because you'd either be making a collisionbox component for every solid voxel, which would be hugely inefficient spacewise, or rolling your own stuff for the collisions and maybe ending up not being able to use Unity's physics at all. And once you're not using the physics, and rolling your own vertex buffers, and rolling your own shaders, what's Unity even doing for you any more? Might as well just be using SDL!

(Alternatively you could have an update function that places colliders for all the voxels that are near something that might collide with them, each frame, which would probably work okay, but it's still quite a mess compared to implementing something more dedicated to voxeling.)

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

quote:

I know it's hitting every single object in the hierarchy, but no color change occurs. If I manually change the tint color on the material in my assets view (pre-execution), it works fine, so the shader itself is properly taking the tint value. I'm just not having any luck changing it run-time.
I just tried doing this using material to no avail (though I have a two-material object). It did work using renderer.materials[1].SetColor("_Color",Color.green).
Or, more easily, renderer.materials[0].color=Color.green.

quote:

Bonus question: what is the variable type on var meshRenderers, as expressed in JavaScript? I know how it would look in C#, but I've never gotten an equivalent var type in JScript that works (and I hate leaving it dynamically typed).
var mr : MeshRenderer[] = whatever.GetComponentsInChildren(MeshRenderer); seems to work, though I can't check the results easily because my MeshRenderer I'm playing with for this is on the top object.

Edit: that's actually what they have in the script reference page for GetComponentsInChildren, so it should be fine (though they used HingeJoint[]).

roomforthetuna fucked around with this message at 19:52 on Jan 10, 2012

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

roomforthetuna posted:

var mr : MeshRenderer[] = whatever.GetComponentsInChildren(MeshRenderer); seems to work, though I can't check the results easily because my MeshRenderer I'm playing with for this is on the top object.
That gets me an InvalidCastException - it's what I would have expected to work.

Specifically:

var meshRenderers : MeshRenderer[] = this.gameObject.GetComponentsInChildren(MeshRenderer);


EDIT: And similarly, no dice on the materials[0]. I even tried:
code:
function TintRecursively(gameObj : GameObject, color : Color)
{
	var meshRenderers = this.gameObject.GetComponentsInChildren(MeshRenderer);
	for (var meshRenderer : MeshRenderer in meshRenderers)
	{
		meshRenderer.material.SetColor("_Color", color);
		for (var meshMaterial : Material in meshRenderer.materials)
		{
			meshMaterial.SetColor("_Color", color);
		}
	}
}
... just on the off chance that it was a multi-shader material, somehow.

How bizarre. I've even temporarily got this running in Update, so it should be spamming it every single frame. Time to poke through my other components... I suspect the way my AnimatedSprite class works may be interfering with me here. Dynamically generated anything in Unity just seems to confuse it, it's built more to assume that every asset exists rigidly somewhere before you hit "go".

Shalinor fucked around with this message at 20:02 on Jan 10, 2012

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

roomforthetuna posted:

You can certainly make your own vertex/index arrays, in a 'Mesh' or 'SharedMesh' object, because I have a function doing that, and you can do custom shaders. You don't so much "tell it to go draw the mesh" as attach the mesh to an object that has a mesh renderer though.

But I think Unity is probably not great for voxeling, because you'd either be making a collisionbox component for every solid voxel, which would be hugely inefficient spacewise, or rolling your own stuff for the collisions and maybe ending up not being able to use Unity's physics at all. And once you're not using the physics, and rolling your own vertex buffers, and rolling your own shaders, what's Unity even doing for you any more? Might as well just be using SDL!

(Alternatively you could have an update function that places colliders for all the voxels that are near something that might collide with them, each frame, which would probably work okay, but it's still quite a mess compared to implementing something more dedicated to voxeling.)

Thanks for the mesh info.

I had also assumed that Unity wasn't a natural platform for voxel development, but someone got it working in the video I linked to the video I linked to earlier so it seems that it is possible. I have no idea how they're doing their physics - voxel collisions are so totally different in nature from most typical systems that you really need to write your own collider class and I don't know if Unity supports that or not.

Seeing that someone made voxels work in Unity has made it an interesting option again. Being able to start off with a nice editor and a lot of tools in place is a huge advantage over rolling your own thing in SDL/SlimDX/whatever.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

PDP-1 posted:

I had also assumed that Unity wasn't a natural platform for voxel development, but someone got it working in the video I linked to the video I linked to earlier so it seems that it is possible. I have no idea how they're doing their physics - voxel collisions are so totally different in nature from most typical systems that you really need to write your own collider class and I don't know if Unity supports that or not.
I read a post from someone saying their blob-voxels were being physicked by having sphere colliders to detect that you're coming near or leaving, and generating a small mesh collider when you approach, so approximately the same thing as what I was saying you could do for 'boxels'.

You can't write your own collider from scratch because PhysX, apparently.

Edit: Found the post again.

roomforthetuna fucked around with this message at 20:45 on Jan 10, 2012

duck monster
Dec 15, 2004

PDP-1 posted:

I know next to nothing about Unity but from the one or two times I've bothered poke around at it I remember seeing warnings against using Boo. The explanation is that (a) it's not really Python and the small differences will drive Python people nuts, and (b) it's not supported on some platforms (iOS?).

But hey, since you're working on a boxely voxely type thing let me ask you this - does Unity support direct creation and manipulation of vertex/index arrays? Can you give the engine a list of vertex/index data and a custom shader and tell it to go draw the mesh? If not, what are you using to draw your voxels?


e: Can anyone recommend a book on Unity development that is written for programmers? Judging by some of the Amazon preview pages it looks like many of the books out there are written for Idea Guys and don't actually go into much depth on the technical/scripting discussions.

Yep. Its not well documented, but little in unity is!. But you definately can.

My first one just created instances of cubes. Obviously thats not the final solution, so from there I've been building a big mesh out of it.

If I wanted to do something serious with voxels, unity would not be my first choice (although I guess you could probably do something fun using the low level GL interface in unity, but..... meh. I'd like to avoid dotnet/mono exposure where possible). I'd probably just roll my own so I had more control over it, and that'd let me do some of the fancier sort of poo poo folks like John Carmac is doing with these bad boys.

I'm just loving around to see if I can understand it better.

duck monster fucked around with this message at 20:58 on Jan 10, 2012

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Thanks for the kind words everybody- I really appreciate it. I have very nerdy, inaccessible hobbies and it can be frustrating not being able to talk about them with anyone. :(

Several people have expressed an interest in learning Forth, and it reminded me of a pretty spiffy programming/puzzle game I saw recently called "Ruby Warrior". In Ruby Warrior you practice elementary hipster-perl by guiding a dude around in dungeons, slaying monsters and rescuing people, all through a command-line interface. Last night I spent a few hours putting together a prototype of a similar game in Forth, except with tile-based graphics!

You've skimmed the first few chapters of Starting Forth, right? You had a look at the Mako crash course to familiarize yourself with the ways my compiler's dialect diverges from Forth as discussed in that book, didn't you? Of course not. Oh well- let's dive in anyway!

First, install Mako on your computer. You'll need Java and Ant. If you have git, clone my repository. Otherwise, grab this zip and put it somewhere handy. Build everything with ant:

code:
red:Mako john$ ant
Buildfile: /Users/john/Desktop/Mako/build.xml

...

BUILD SUCCESSFUL
Total time: 1 second
The maker script is an easy way to invoke the compiler. Give it a filename and the --run flag to build and run your code. Like this:
code:
red:Mako john$ ./maker examples/Warrior/BasicHero.fs --run
00000: (PC)            21520
00001: (DP)            21981
00002: (RP)            22031

(holy poo poo what IS all this?)

21976:                 CONST 21850
21978:                  STOR (going-down)
21979:                   RET
21980:                   RET
21981: (data-stack)    <<< 50 words >>>
22031: (return-stack)  <<< 50 words >>>
22081: (sprites)       <<< 1024 words >>>

23105 words, 90.254 kb.
Entered level 0 
Look, Ma- I made it to level 0 !




Glorious! It lives! Enjoy the foibles of BasicHero- it does OK on the first few levels of the game, but it's really about as dumb as a sack of hammers. You can do better! Make a copy of the HeroTemplate.fs file in the examples/Warrior/ directory and get ready to fill in the brains.

code:
:const start-level 0
:include "Warrior.fs"

: level ( n -- ) ;
: tick ( -- ) ;
We declare a constant that specifies the level of the dungeon we want to start on. For now, let's just leave that alone. We then include "Warrior.fs", which contains the meat of the simulation and the level data. You can have a look later. What's really important are those last two lines- skeletal declarations for the two procedures that comprise a hero controller. level gets called when you start a new level, and the comment (those things in useless parentheses) says it takes the level number on the stack and leaves nothing. We don't need this method to do anything yet, but we need to follow that method contract so we should discard that argument:

code:
: level ( n -- )
	drop
;

: tick ( -- ) ;
Given the complexity of the first level, we need a sophisticated strategy. Like walking east, oblivious to everything. Just push the direction we want on the stack and then say "walk".

code:
: level ( n -- )
	drop
;

: tick ( -- )
	east walk
;
code:
Entered level 0 
Walked east.
Walked east.
Walked east.
Walked east.
Walked east.
Walked east.
Walked east.
Walked east.
Descended the stairs...
Entered level 1
Awesome! We beat the first level and-



code:
...
Walked east.
Cannot walk east.
  Final Score:  0 
  Steps taken:  19 
  Observations: 0
-slammed headfirst into a wall. Let's revise our strategy and pay attention to those walls. If we're blocked east, go north.

code:
: level ( n -- )
	drop
;

: tick ( -- )
	east look solid =
	if north else east then walk
;
Observe how if...else...then can be used like a ternary operator. That gets us a whole three steps further. How about we design our hero to alternate between "east mode" and "north mode" when he's blocked? We'll want to keep track of a bit of state, so we allocate a variable and we can use level to reset our direction every time we complete a level.

code:
:var dir
: level       drop east dir ! ;
: change-dir  dir @ north = if east else north then dir ! ;
: tick        dir @ look solid = if change-dir then dir @ walk ;
Two rooms down, more to go. Get gems! Slay slimes! Documentation!
Thoughts, anybody?

Internet Janitor fucked around with this message at 01:36 on Jan 11, 2012

gonadic io
Feb 16, 2011

>>=

Internet Janitor posted:

...Forth AI challenge...
Thoughts, anybody?

This looks really good and I'll certainly be trying it out!

It reminds me of the AI challenges that Google throws on twice a year at http://aichallenge.org/. People had submitted support (interfacing with the game and so on) for more than 20 languages, perhaps next time we'll see Forth in there!

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
I would love to see people's heroes. Combat is kinda threadbare and since Forth is a systems programming language there are a million ways to shoot yourself in the foot, but I intend to keep tinkering with it for a few days and adding things. For beginner-friendliness, the Warrior system can sometimes detect stack over/underflows for you!

Your Computer
Oct 3, 2008




Grimey Drawer
This is awesome! Definitely going to mess around with this, as I'm reading up on Forth and this is way more fun than doing calculator-stuff :allears:

Do you make the graphics yourself? I really like it when people make proper lowres graphics and not just throw in a bunch of pixel resolutions and go "YAY PIXELS, IT'S INDIE"


Also, since I'm using Windows I threw in a 'maker.bat' file with
code:
java -jar dist/Maker.jar %1 %2
(Might be interesting for other people using Windows for this!)

TheresaJayne
Jul 1, 2011
reminds me of redcode, I will certainly look at it - but then i know forth from lots of playing around with tinymuck and derivatives.

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Shalinor posted:

How bizarre. I've even temporarily got this running in Update, so it should be spamming it every single frame. Time to poke through my other components... I suspect the way my AnimatedSprite class works may be interfering with me here. Dynamically generated anything in Unity just seems to confuse it, it's built more to assume that every asset exists rigidly somewhere before you hit "go".
Figured this out. It had nothing to do with my code, and everything to do with the way I'd set up my materials.

gently caress you, Unity 3D. Crap like this is why we stopped using you for our next project.

EDIT: Wait, wait... there's a tint argument on the particle material UI called "Tint Color." Don't tell me... it doesn't use base color for its tint. "Because".

EDIT: Yep, there, works flawlessly with "_TintColor". And Tint Color also works differently, in that it can ramp the color value as well as dampen it, which is... fine, I guess, if a bit arbitrary. See aforementioned "gently caress you, Unity 3D".

Shalinor fucked around with this message at 18:41 on Jan 11, 2012

Unormal
Nov 16, 2004

Mod sass? This evening?! But the cakes aren't ready! THE CAKES!
Fun Shoe

Shalinor posted:

Figured this out. It had nothing to do with my code, and everything to do with the way I'd set up my materials.

gently caress you, Unity 3D. Crap like this is why we stopped using you for our next project.

EDIT: Wait, wait... there's a tint argument on the particle material UI called "Tint Color." Don't tell me... it doesn't use base color for its tint. "Because".

EDIT: Yep, there, works flawlessly with "_TintColor". And Tint Color also works differently, in that it can ramp the color value as well as dampen it, which is... fine, I guess, if a bit arbitrary. See aforementioned "gently caress you, Unity 3D".

What are you using instead, if I might ask?

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Unormal posted:

What are you using instead, if I might ask?
UDK. It has a near vertical learning curve, but once you're up, I find the toolset to be substantially superior.

For small mobile games, we might still go with Unity over UDK, but for any project likely to take more than a few months... ugh, yeah, never using Unity 3D again.

Adbot
ADBOT LOVES YOU

Unormal
Nov 16, 2004

Mod sass? This evening?! But the cakes aren't ready! THE CAKES!
Fun Shoe

Shalinor posted:

UDK. It has a near vertical learning curve, but once you're up, I find the toolset to be substantially superior.

For small mobile games, we might still go with Unity over UDK, but for any project likely to take more than a few months... ugh, yeah, never using Unity 3D again.

Ah yeah; though UDK doesn't seem to have android support yet, so that's a reasonable black mark for mobile development until it does.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply