RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
The curse of extended down times for sloppy coders
 
Post new topic Reply to topic Goto page 1, 2, 3  Next 
View previous topic - View next topic  
Author Message
XMark
Guitar playin' black mage


Joined: 30 May 2002
Posts: 870
Location: New Westminster, BC, Canada

PostPosted: Mon Nov 03, 2003 2:27 am    Post subject: The curse of extended down times for sloppy coders [quote]

Blarg.

Blarg, I say! Blarg, blarg, and blarg again!

Now I'm learning first-hand why all my programming professors tell me to comment the crap out of my code and do everything the neat and tidy way. I've had a few attempts going back into the code of ARC Legacy Gold after my 7.5-month hiatus and I'm bamboozled. It's like trying to read another language. And since I don't understand what I'm getting back into, the stuff that I add to it is even more out of whack, it's like a train wreck.

This would be the second time I'm doing this, but it seems that I'm going to have to re-program the engine from scratch, but I'm not going to make it the same engine, that would be a waste of time. Might as well try another jump forward and upgrade the engine. Here's what I'm thinking: screw tiles. I'm gonna go for the "big bitmap in the background" technique for maps. Two big bitmaps for two layers, the top one mostly transparent. Plus another bitmap for collision detection. True pixel*pixel movement and all that jazz.

I suppose it's for the best...
_________________
Mark Hall
Abstract Productions
I PLAYS THE MUSIC THAT MAKES THE PEOPLES FALL DOWN!
Back to top  
Fooolking
Xmark's Caged Bitch


Joined: 16 Dec 2002
Posts: 79
Location: Toronto, Ontario. Canada

PostPosted: Mon Nov 03, 2003 3:35 am    Post subject: Hahahaha! [quote]

I don't think the NPCs will like you for rending their world apart and building it up again.

X-Mark is a cruel God.

Speaking of which, I should have or atleast start getting some drawings ready tomorrow. Not all. But, I have a few old ones that I don't dread bringing back into the light of day and a couple new sketches.

I will dump them on some free webspace and e-mail you the link.
_________________
Never milk cows that have uni-brows.
Back to top  
grenideer
Wandering Minstrel


Joined: 28 May 2002
Posts: 149

PostPosted: Mon Nov 03, 2003 7:15 am    Post subject: [quote]

man, getting in the habit of commenting code is a must. i comment the crap outta my C++.
_________________
Diver Down
Back to top  
XMark
Guitar playin' black mage


Joined: 30 May 2002
Posts: 870
Location: New Westminster, BC, Canada

PostPosted: Mon Nov 03, 2003 8:09 am    Post subject: [quote]

could someone point me to a good tutorial or some example source code of using the Lua scripting language in DJGPP?
_________________
Mark Hall
Abstract Productions
I PLAYS THE MUSIC THAT MAKES THE PEOPLES FALL DOWN!
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Mon Nov 03, 2003 10:52 am    Post subject: [quote]

Lua shouldn't be any different because of the compiler. If you just want to compile Lua itself, I can't help you there. I just got it to work with MinGW, gcc in Linux and MSVC.

I've upgraded our Moonlight engine to use Lua 5.0, not sure if I released anything of that yet, though I seem to remember a small engine demo release. The license is GPL.

See: http://forums.rpgdx.net/viewtopic.php?p=5973#5973

The engine has been progressing since then though, but it might be good as a Lua using example.
Back to top  
janus
Mage


Joined: 29 Jun 2002
Posts: 464
Location: Issaquah, WA

PostPosted: Mon Nov 03, 2003 11:52 am    Post subject: [quote]

I've never really needed to comment my code. But that's because I mostly write extremely verbose OO VB code.
Back to top  
Mandrake
elementry school minded asshole


Joined: 28 May 2002
Posts: 1341
Location: GNARR!

PostPosted: Mon Nov 03, 2003 3:37 pm    Post subject: [quote]

Lua is good- but the amount of tut's on using Lua are scarce. But it is easy to extend fucntions- but getting OO style code is harder. That's one of the reason I mostly extend via python- it has built in support of OO code. It is a bit more complicated to extend than Lua, but it does have it's benefits.

EDIT:
also- do you want to keep the sprites the same?

I'm sending you the archeoligists sprites today.
_________________
"Well, last time I flicked on a lighter, I'm pretty sure I didn't create a black hole."-
Xmark

http://pauljessup.com
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Mon Nov 03, 2003 4:29 pm    Post subject: [quote]

Ok, for my next scripting lib, I'm going to look into Python. Extending Lua to do OO has been rather difficult indeed and it's still rather rough on the edges. For example, I question the efficiency of the system and it's also missing some aspects of OOP that I simply couldn't figure out how to do in Lua.

Also, the Google directory has 18 pages on Lua and a whopping 437 pages on Python. Now that must have a reason. :-)
Back to top  
Mandrake
elementry school minded asshole


Joined: 28 May 2002
Posts: 1341
Location: GNARR!

PostPosted: Mon Nov 03, 2003 5:18 pm    Post subject: [quote]

right- and with Python you already have a large base of devr's. And books on the subject, and lots of tutorials. Finding any info on Lua is like pulling teeth.

But, I did like the simplicity of extending basic lua- just adding a function was really insanely simple. But doing something complicated things become more and more complicated and less and less documented. Python, OTOH, to do something simple, like extend a function, takes more work than it probably should, but adding in classes and using it's OOP is about as hard as adding a function.
_________________
"Well, last time I flicked on a lighter, I'm pretty sure I didn't create a black hole."-
Xmark

http://pauljessup.com
Back to top  
Rainer Deyke
Demon Hunter


Joined: 05 Jun 2002
Posts: 672

PostPosted: Mon Nov 03, 2003 8:27 pm    Post subject: [quote]

I hate the "big bitmap" approach and much prefer tiles. But that's just my opinion.
Back to top  
golrien
Milk Maid


Joined: 09 Jun 2002
Posts: 40
Location: Shropshire, England

PostPosted: Mon Nov 03, 2003 10:21 pm    Post subject: [quote]

I hardly ever comment code; in a good language, the code *is* the documentation. What a line does should be instantly obvious. The only thing I comment is *why* it does something; if something looks totally out of place, there'll be
// MONKEY CHECKING, DO NOT REMOVE
or whatever. But the only bits of code that I can't understand after 6 months are the ones I've written to hack around other code, things like my old DirectX wrapper (now I just use allegro, so much nicer).

ps. I'm writing my own scripting language, it's certainly entertaining
Back to top  
X_Mark
Guest





PostPosted: Tue Nov 04, 2003 2:35 am    Post subject: [quote]

Well, I'm not really interested in extending Lua to OO or whatever it is you're doing. I basically just wanna know how to do something like this: (I'm not sure if this is correct Lua syntax but you get the idea)

Scripting code:
Code:
MovePlayer(3)



My code:
Code:

function MovePlayer(int x)
{
 playerx += x
}


or is Lua something different than what I'm thinking?
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Tue Nov 04, 2003 1:05 pm    Post subject: [quote]

That's the part which Mandrake mentions to be very simple with Lua, and it is. You'd define your C function like:

Code:
void MovePlayer(int x)
{
    playerx += x;
}

int L_MovePlayer(lua_State *L)
{
    MovePlayer(lua_tonumber(L, 1));
    return 0;
}

...

// Create Lua state
L = lua_open();

// Register engine functions
lua_register(L, "MovePlayer", L_MovePlayer);
...


The "L_" prefix is just added because in my opinion it's nice to differentiate between Lua C and normal C functions, and this way, you can also conveniently call the function from your C code. You could have just written one function though.

Of course, when you introduce error checking on the parameters or introduce your own datatypes as parameters, things get more and more elaborate (see Defining C Functions in the reference manual). Personally, I got tired of writing all that pretty soon so I wrote functions that worked like printf, which would push or pop variables on the stack and and do the error checking. As follows:

Code:
int l_add_object(lua_State *L)
{
   int x, y;
   const char* type;
   Map* map;

   getLuaArguments(L, "iism", &x, &y, &type, &map);

   return putLuaArguments(L, "o", map->addObject(x, y, type));
}


If you don't have problems with GPL... :-)
Back to top  
Mandrake
elementry school minded asshole


Joined: 28 May 2002
Posts: 1341
Location: GNARR!

PostPosted: Tue Nov 04, 2003 1:23 pm    Post subject: [quote]

Yeah, if you jsut want to extend a library/engine by sending functions to a scripting language, you can't get that any simpler than with Lua. If you want OO programming, module-support, and other nifty stuff, you than want to go with Python. Also- python is well documented (esp in the department of extending it), while Lua...well, the manual can be a bit much the first few times you try and read it.
_________________
"Well, last time I flicked on a lighter, I'm pretty sure I didn't create a black hole."-
Xmark

http://pauljessup.com
Back to top  
XMark
Guitar playin' black mage


Joined: 30 May 2002
Posts: 870
Location: New Westminster, BC, Canada

PostPosted: Thu Nov 06, 2003 6:52 am    Post subject: [quote]

heh, cool. So now I just wanna know which thing I'm supposed to download from the Lua site (I'm doing it in Dev-C++/MingW right now).

I tried the source code and followed the directions by putting all the .c files in a project and compiling it, but I just got pages full of errors. What am I doing wrong? and if there's no answer is there somewhere I can just download it precompiled for MingW?
_________________
Mark Hall
Abstract Productions
I PLAYS THE MUSIC THAT MAKES THE PEOPLES FALL DOWN!
Back to top  
Post new topic Reply to topic Page 1 of 3 All times are GMT
Goto page 1, 2, 3  Next 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum