--- Log opened Tue Mar 24 00:00:27 2009 |
00:14 | | Attilla_ [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has quit [Connection reset by peer] |
00:14 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has joined #code |
00:14 | | mode/#code [+o Attilla] by ChanServ |
00:15 | | * gnolam stabs Intellisense with something dull and rusty. |
00:33 | <@ToxicFrog> | Horspool search: sorted! |
00:41 | | mac [~macdjord@Nightstar-9795.129-97-124-126.uwaterloo.ca] has joined #code |
00:42 | < mac> | Can someone help me with a quick BASH incantation? |
00:44 | < mac> | I have a command, 'cmd < [name].pre > [name].post'. I need the incantation that will apply that across all files *.pre in the current folder. |
00:45 | <@Derakon> | ls *.pre | perl -ne 'chomp; /(.*).pre/; `cmd < $_ > $1.post`' |
00:45 | < mac> | Thanks. |
01:01 | <@ToxicFrog> | Also, without invoking perl: |
01:01 | <@Derakon> | You got a problem with chainsaws, TF? >.> |
01:02 | <@ToxicFrog> | for file in *.pre; do cmd < "$file" > "${file/.pre/.post}"; done |
01:03 | < GeekSoldier> | just swiss army ones, I suppose. |
01:11 | < mac> | ... fuck. And people wonder why *nix is considered confusing and scary. |
01:13 | < mac> | I just mistyped 'rm *.compare' as 'rm * .compare'. Now my entire directory is empty. No confirmation. No undo. |
01:13 | <@Derakon> | Whoops. |
01:13 | <@Derakon> | How much work did you lose? |
01:16 | < mac> | All my test files and results. About 20 mintes to retype them, and another 5 to rerun the tests. Fortunantly, I like using an IDE, so my primary copy of the actual program I'm debugging is on my Windows laptop, not on the Linux system I'm sshed into. |
01:16 | <@Derakon> | Okay, that's not so bad. |
01:17 | <@Derakon> | I had a friend type "rm -rf * ~" once. He had to go get the daily backup of his home directory. |
01:17 | <@Derakon> | Look at it this way: now you'll check your commandline anytime you're doing an rm with a '*' involved. :) |
01:18 | < mac> | Also fortuantly, the test files based on the submission results were in a subfolder, and therefore spares. If i'd lost /them/, I have no way of recreating them at all. |
01:36 | | Janus [~clairvoir@Nightstar-9198.vdsl.bright.net] has joined #code |
01:49 | | gnolam [lenin@Nightstar-1382.A163.priv.bahnhof.se] has quit [Quit: Z?] |
02:30 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has quit [Quit: <Insert Humorous and/or serious exit message here>] |
04:18 | | mac is now known as macdjord |
04:46 | < Janus> | Um, um. Um. Uh. May I ask if I can ask a question? |
04:46 | | * Derakon facepalms. |
04:47 | | Derakon changed the topic of #code to: FORTH LOVE IF HONK THEN | Have a pastebin! http://paste.ubuntu.com | Channel mode +U, ask for voice to post links. | Monologues permitted. | See #projecteuler for discussions about http://projecteuler.net | Don't ask to ask to ask, just ask |
04:49 | | Rhamphoryncus [~rhamph@Nightstar-7184.ed.shawcable.net] has joined #code |
04:51 | < Janus> | Well, that answers my next question. |
04:52 | <@Reiver> | Ask it. :p |
04:55 | < Janus> | Er. Okay. Is it good style to write the script/content/stage part of a game as part of the, um, code, in c++? Like, instead of putting it in a text file and trying to interpret from that? |
04:55 | <@ToxicFrog> | As a general rule, no. |
04:56 | <@Derakon> | Ideally you read the level data from resource files and the game logic is handled in a scripting language. |
04:56 | <@ToxicFrog> | It's slower to develop (both because it's harder to write, and because you need to rebuild after each change) and it hurts moddability. |
04:57 | <@ToxicFrog> | Ideally, one would write the game engine in C/++ and the game logic, as Der says, in a scripting language. |
05:00 | <@ToxicFrog> | (for very small games this may be more trouble than it's worth, but probably not) |
05:00 | < Janus> | That's what I thought too. But when I try to design how the scripts would be loaded and interpretted, I worry I'll be restricting what I can do, content wise. |
05:01 | <@Derakon> | Adding scripting should liberate you to do more, not restrict you to do less... |
05:02 | | Syloqs-AFH [Syloq@Admin.Nightstar.Net] has quit [Connection reset by peer] |
05:04 | < Janus> | I'm probably approaching incorrectly, haha |
05:06 | <@McMartin> | The easiest way to do this is to use a scripting language that's already been written instead of rolling your own. |
05:06 | <@McMartin> | Lua is popular for this, especially if the core engine is C or C++. |
05:06 | <@Derakon> | Or you could write the core engine itself in a scripting language~ |
05:08 | <@McMartin> | As long as it has bindings to your output model. |
05:09 | <@McMartin> | So yeah, if this is "Man, writing a game would be awesome. I suppose step 1 would be to learn to program", head off to pygame.org. |
05:10 | <@McMartin> | It has a bunch of tutorials and Python is quite good at both having buttloads of stuff you can steal along with getting the Hell out of your way when you don't want said stuff |
05:10 | < Janus> | I'm sadly too stuck in C++ to migrate easily. And I've already wrote a good portion of this game already, some graphics too~ |
05:10 | < Janus> | Pygame is awesome~ It's my first love. |
05:10 | <@Derakon> | Graphics are language-agnostic. Code is a different matter. |
05:13 | < Janus> | (I actually have a small executable for it so far. Just a title screen though. Deploying Visual C++ executables are surprisingly painful) |
05:14 | < Janus> | Lua is an addin library? I thought it was it's own thing. Hm! |
05:14 | | * Janus hms all over the carpet |
05:14 | <@ToxicFrog> | It's both. |
05:14 | <@Derakon> | Lua has a very straightforward C library for binding it to C. |
05:15 | <@ToxicFrog> | You can either use the interpreter as a standalone program (which can load libraries written in C and C++ to provide extra features), or link liblua into a C or C++ program to let it use Lua. |
05:16 | <@ToxicFrog> | In fact, the interpreter is just a simple case of the latter; a small C program that creates a Lua VM, optionally loads one or more files into it, executes it/them, and then loops reading code from the terminal and running it. |
05:16 | <@Vornicus> | Supreme Commander and WoW both use Lua as their scripting language of choice. |
05:17 | < Tarinaky> | Homeworld 2 as well. |
05:18 | <@ToxicFrog> | And Spellforce. |
05:21 | <@McMartin> | And Grim Fandango. |
05:21 | <@ToxicFrog> | And a whole bunch of others which it's too late at night for me to remember at the moment~ |
05:21 | < Janus> | Hum... so, you register functions to it, then it can call those functions from the script? |
05:21 | <@ToxicFrog> | Pretty much, yes. |
05:21 | < Janus> | That's so awesome! |
05:21 | <@Derakon> | It may help to think of it as creating a C/C++ API that your Lua scripts can invoke. |
05:22 | <@ToxicFrog> | You can do more complicated things with it, like exporting whole C++ objects to Lua in such a way that they look and behave like Lua objects (this is how lua file IO works, for example) |
05:22 | <@Vornicus> | And then there's the Lua-python bindings, which are disturbingly cool. |
05:22 | <@ToxicFrog> | Or hooking variable accesses so that getting/setting certain variables from Lua triggers C++ calls. |
05:23 | <@ToxicFrog> | (it works the other way too, of course; C++ can call Lua code and adjust Lua variables.) |
05:23 | <@ToxicFrog> | The Lua/Python bindings are ridiculously awesome, yes. |
05:30 | | * Janus plays with it. Wheeee |
05:39 | <@ToxicFrog> | Its |
05:39 | <@ToxicFrog> | It's a pretty tasty language, and if I did not require sleep, I would stay and answer any questions you might have. |
05:40 | <@ToxicFrog> | But, I do. So, goodnight! |
05:40 | < Janus> | Sleep! I will read the manuel for now, then return when I'm not as nooby~ |
05:40 | | * Janus won't be returning for a looooong time. |
05:41 | < Janus> | Thanks for the advice! I should be slep too. Slep |
05:41 | | * Janus SLEP |
05:41 | | Janus [~clairvoir@Nightstar-9198.vdsl.bright.net] has left #code [] |
06:15 | | thalass [~thalass@Nightstar-24524.dyn.iinet.net.au] has joined #code |
06:26 | | AnnoDomini [~farkoff@Nightstar-29498.neoplus.adsl.tpnet.pl] has joined #Code |
06:26 | | mode/#code [+o AnnoDomini] by ChanServ |
06:29 | | Derakon is now known as Derakon[AFK] |
06:37 | | C_tiger [~cheng@Nightstar-5625.hsd1.ca.comcast.net] has quit [Connection reset by peer] |
06:38 | | C_tiger [~cheng@Nightstar-5625.hsd1.ca.comcast.net] has joined #code |
06:38 | | mode/#code [+o C_tiger] by ChanServ |
06:52 | | macdjord is now known as madjord|t-5 |
06:56 | <@AnnoDomini> | How do I compare a c-string and something in quotes? |
06:59 | | madjord|t-5 [~macdjord@Nightstar-9795.129-97-124-126.uwaterloo.ca] has left #Code [Bed...] |
07:22 | <@McMartin> | strcmp, in string.h |
07:22 | <@McMartin> | Returns -1/1/0 for first argument being less than/greater than/equal to the second. |
07:24 | <@AnnoDomini> | Will this work with a single char and a character in quotes? |
07:25 | <@Vornicus> | a char and a char* are two different things |
07:30 | <@AnnoDomini> | I guess this means no. |
07:31 | <@Vornicus> | Two chars can be compared directly. |
07:47 | | gnolam [lenin@Nightstar-1382.A163.priv.bahnhof.se] has joined #Code |
07:48 | | mode/#code [+o gnolam] by ChanServ |
07:57 | | McMartin [~mcmartin@75.36.154.ns-3831] has quit [Operation timed out] |
07:59 | | McMartin [~mcmartin@Nightstar-3361.dsl.pltn13.sbcglobal.net] has joined #code |
07:59 | | mode/#code [+o McMartin] by ChanServ |
08:03 | | ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has quit [Operation timed out] |
08:08 | | ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has joined #code |
08:08 | | mode/#code [+o ToxicFrog] by ChanServ |
08:27 | | Vornicus [Vornicus@Admin.Nightstar.Net] has quit [Quit: ] |
09:08 | | KarmaBot [AnnoDomini@Nightstar-29498.neoplus.adsl.tpnet.pl] has quit [Ping Timeout] |
09:09 | | EvilDarkLord [~jjlehto3@Nightstar-9591.cs.hut.fi] has quit [Ping Timeout] |
09:10 | | KBot [AnnoDomini@Nightstar-29498.neoplus.adsl.tpnet.pl] has joined #Code |
09:10 | | EvilDarkLord [~jjlehto3@Nightstar-9591.cs.hut.fi] has joined #code |
09:11 | | EvilDarkLord is now known as NSGuest-122 |
09:13 | | KBot is now known as KarmaBot |
09:39 | | Rhamphoryncus [~rhamph@Nightstar-7184.ed.shawcable.net] has quit [Quit: Rhamphoryncus] |
09:50 | | thalass is now known as Thalass |
09:56 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has joined #code |
09:56 | | mode/#code [+o Attilla] by ChanServ |
10:34 | | somnolence [~somnolenc@203.160.1.ns-3171] has quit [Client exited] |
10:38 | | somnolence [~somnolenc@203.160.1.ns-3171] has joined #code |
10:41 | | GeekSoldier [~Rob@Nightstar-8573.midstate.ip.cablemo.net] has quit [Ping Timeout] |
11:37 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has quit [Quit: <Insert Humorous and/or serious exit message here>] |
14:01 | | Tarinaky [~Tarinaky@88.83.110.ns-10776] has quit [Ping Timeout] |
14:10 | | Tarinaky [~Tarinaky@88.83.110.ns-10776] has joined #code |
14:32 | <@AnnoDomini> | http://pastie.org/425407 |
14:32 | <@AnnoDomini> | Here's what I'm trying to do. |
14:50 | <@gnolam> | printf(&buf); |
14:50 | <@gnolam> | Err... |
14:50 | <@gnolam> | Don't. :P |
14:52 | <@AnnoDomini> | It wasn't having printf(buf); |
14:52 | <@gnolam> | 1. Never send raw strings into printf - always do printf("%s", foostring) instead to prevent Bad Things. 2. It's not null terminated. 3. If you insist on using C++ I/O (yech!) stream to std::cout. |
14:53 | <@gnolam> | Also, those "'s should be ''s, as you're comparing characters. |
14:54 | <@gnolam> | And as you're comparing characters, the strcmp should go. |
14:57 | <@gnolam> | Also... you'll have an out-of-bounds access if any of the first three if statements are true after a \n. |
14:57 | <@gnolam> | And now, back to dinner. |
15:03 | <@AnnoDomini> | Could you explain the out-of-bounds bit? |
15:03 | | Syloq [Syloq@Admin.Nightstar.Net] has joined #code |
15:04 | | Syloq is now known as Syloqs-AFH |
15:08 | <@ToxicFrog> | I'm not seeing it myself, the ++i deals with that |
15:08 | <@ToxicFrog> | I do have some comments to make once I get to campus, though~ |
15:09 | <@AnnoDomini> | http://pastie.org/425447 <- Here's an updated version, which works, sorta. |
15:15 | | KBot [AnnoDomini@Nightstar-29342.neoplus.adsl.tpnet.pl] has joined #Code |
15:15 | | AnnoDomini [~farkoff@Nightstar-29498.neoplus.adsl.tpnet.pl] has quit [Ping Timeout] |
15:16 | | KarmaBot [AnnoDomini@Nightstar-29498.neoplus.adsl.tpnet.pl] has quit [Ping Timeout] |
15:18 | | KBot is now known as KarmaBot |
15:22 | | AnnoDomini [~farkoff@Nightstar-29342.neoplus.adsl.tpnet.pl] has joined #Code |
15:22 | | mode/#code [+o AnnoDomini] by ChanServ |
15:35 | <@ToxicFrog> | AnnoDomini: ok. |
15:36 | <@ToxicFrog> | Notes on printf: the format string you want is "%c" |
15:37 | <@ToxicFrog> | Or, since you're using C++ IO anyways, std::cout << buf; |
15:37 | <@ToxicFrog> | You shouldn't be using literals for the gamestate array; give them proper names: |
15:37 | <@ToxicFrog> | enum TileTypes { |
15:38 | <@ToxicFrog> | TILE_CORRIDOR = 0, |
15:38 | <@ToxicFrog> | TILE_WALL, |
15:38 | <@ToxicFrog> | TILE_EMPTY, |
15:38 | <@ToxicFrog> | NROF_TILE_TYPES |
15:38 | <@ToxicFrog> | }; |
15:39 | <@ToxicFrog> | Finally...what happens if someone feeds you a malformed map? |
15:39 | < Tarinaky> | I had a look at some of the documentation for Python and I'm having difficulty working out when things're references and when things're values. |
15:40 | <@AnnoDomini> | ToxicFrog: Cthulhu rises from his sleep. |
15:40 | < Tarinaky> | If I have a variable x = 10 and call f(x). Can f change the value of x in the caller's scope? |
15:41 | | Derakon[AFK] is now known as Derakon |
15:49 | <@ToxicFrog> | Tarinaky: not to my knowledge. |
15:50 | < Tarinaky> | What if x=AClass()? |
16:14 | <@ToxicFrog> | In that case I believe it is a reference, but my Python is rusty. |
16:14 | <@ToxicFrog> | That said, it's still not pass by reference. |
16:15 | <@ToxicFrog> | It's pass by value and the value is a reference. |
16:15 | < Tarinaky> | Confusin'. Lol. |
16:15 | <@ToxicFrog> | That is to say, if f(x) does x.foo = "bar", the caller will see that change reflected |
16:15 | <@ToxicFrog> | But if it does x = AnotherClass(), it won't change the value of the caller's x |
16:32 | | NSGuest-122 is now known as EvilDarkLord |
17:16 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has joined #code |
17:16 | | mode/#code [+o Attilla] by ChanServ |
17:22 | | Rhamphoryncus [~rhamph@Nightstar-7184.ed.shawcable.net] has joined #code |
17:26 | <@ToxicFrog> | AnnoDomini: that implies that your map reading code should be more robust :P |
17:39 | <@AnnoDomini> | God damn it. How the hell do you work with the analog sticks so you don't fall off the thrice-damned pegasus?! |
17:39 | <@Derakon> | What game is this now? |
17:40 | <@AnnoDomini> | God of War 2. |
17:40 | <@AnnoDomini> | How the hell do I dodge those purple balls, argh. |
17:46 | | Rhamphoryncus [~rhamph@Nightstar-7184.ed.shawcable.net] has quit [Quit: Rhamphoryncus] |
18:43 | | Rhamphoryncus [~rhamph@Nightstar-7184.ed.shawcable.net] has joined #code |
20:02 | | * AnnoDomini ponders what kinds of tiles he needs. |
20:12 | <@gnolam> | Ceramic. |
20:13 | | * AnnoDomini adds TILE_FLOOR_CERAMIC. |
20:39 | | * gnolam teleconferences as Rome burns. |
20:41 | <@AnnoDomini> | Whoah, massive slowdown. |
20:42 | <@AnnoDomini> | And all I did was add bitmaps. |
20:43 | <@McMartin> | Are you doing SDL_DisplayFormat or SDL_DisplayFormatAlpha on them after load? |
20:44 | <@McMartin> | Because if not it's basically reconverting the sprite to display format on every blit. |
20:45 | <@AnnoDomini> | http://pastie.org/425795 <- I'm using this function for my bitmaps. |
20:45 | <@McMartin> | I, um. |
20:46 | | * AnnoDomini braces for beatings. |
20:46 | <@McMartin> | You're reloading it from disk every time you blit it. |
20:46 | <@AnnoDomini> | The disk doesn't seem active, though. |
20:46 | <@AnnoDomini> | LED isn't flashing. |
20:46 | <@McMartin> | The OS is caching it for it. |
20:46 | <@Derakon> | That doesn't mean that SDL isn't doing the work to read the file contents. |
20:46 | <@McMartin> | Otherwise it would be 100,000 times slower. |
20:47 | <@Derakon> | As a general rule, load your surfaces when the program starts up, and keep them around. |
20:47 | <@Derakon> | Then your drawEntireBitmap function takes as arguments (screen, surface, x, y) instead of (screen, path, x, y). |
20:47 | <@McMartin> | If you aren't editing them, you will want to set up your screen first and use the DisplayFormat function I mentioned before to optimize the later blits. |
20:50 | <@AnnoDomini> | So I should perhaps make an array of surfaces, indexed by the enumed thingies, which I would use instead of loading from disk every time. That much I get. I will require more instruction on how to use DisplayFormat. |
20:51 | <@McMartin> | I'll have to check the doc wiki |
20:52 | <@McMartin> | But I seem to recall it sort of magically reformats the surface to match the video display |
20:52 | <@McMartin> | What I don't recall is if it produces a new one requiring you to free the old |
20:52 | <@AnnoDomini> | Okay. Magic I can understand. |
20:53 | <@McMartin> | More to the point, it does it once and lets you keep the result; otherwise it has to do it on every blit |
20:53 | <@McMartin> | OK, it isn't actually freed |
20:54 | <@McMartin> | ... do these bitmaps have transparencies in them? |
20:54 | <@AnnoDomini> | I kinda doubt that. |
20:54 | <@AnnoDomini> | How do I tell? |
20:54 | <@Derakon> | If they're BMPs, they don't, McM. |
20:54 | <@McMartin> | http://www.libsdl.org/cgi/docwiki.cgi/SDL_DisplayFormat is the function you want, then |
20:55 | <@McMartin> | That has a link to "DisplayFormatAlpha", which is what you will want for cases where they eventually do. |
20:55 | <@McMartin> | Your character sprites will. (Consider PNG for this.) |
20:55 | <@Derakon> | As a general rule, I'd say: use PNG for everything, use DisplayFormatAlpha for everything. |
20:56 | <@McMartin> | PNG will require you to install SDL_image, though, so fo rnow you can probably hold off |
20:56 | <@AnnoDomini> | No transparency is good enough for DF. :P |
20:56 | <@McMartin> | It's not for Super Mario Brothers, though. |
20:56 | <@Derakon> | ...for a moment there I thought you were saying that you were reimplementing DF. |
20:56 | <@AnnoDomini> | NO. |
20:57 | <@AnnoDomini> | Somebody else is doing that. |
20:58 | <@AnnoDomini> | Actually, now that I look at it, my function does use DisplayFormat. |
20:58 | <@AnnoDomini> | Though perhaps I should free the other surface, too. |
21:00 | <@McMartin> | The logic you want is: |
21:00 | <@McMartin> | - load the image. If this doesn't work, fail. |
21:00 | <@McMartin> | - try convert the image to the display format. |
21:00 | <@McMartin> | - If this worked, free the image you loaded and return the new one for use. |
21:00 | <@McMartin> | - Otherwise, take the performance hit and return the old one for use. |
21:01 | <@Derakon> | (And log a warning) |
21:02 | <@AnnoDomini> | http://pastie.org/425813 <- How does this look? |
21:03 | <@Derakon> | You should do DisplayFormat as part of loading the image. |
21:03 | <@Derakon> | Not as part of displaying it. |
21:03 | <@AnnoDomini> | Ah. |
21:04 | <@McMartin> | If it wasn't done in advance, it automatically happens as part of displaying it; that's what you're trying to optimize away here. |
21:05 | <@AnnoDomini> | http://pastie.org/425818 <- How 'bout now? |
21:06 | <@Derakon> | I don't recall offhand what the src and dest rects are for, but yeah, that looks fine. Though I'd quibble with the variable name "bitmap". :) |
21:06 | <@Derakon> | They're surfaces, not bitmaps, after all. |
21:07 | <@AnnoDomini> | http://pastie.org/425818 <- Happy now? ;) |
21:07 | <@Derakon> | :p |
21:07 | <@Derakon> | Your function name is off. ;) |
21:07 | <@Derakon> | (I'll stop now) |
21:08 | | * AnnoDomini edits that too. |
21:13 | <@AnnoDomini> | http://pastie.org/425827 <- Trying to do the other part. Look good? |
21:16 | <@AnnoDomini> | Somehow, I think there's something wrong here. |
21:17 | <@Derakon> | That looks fine to me, except that I would prefer to return the image instead of passing a pointer. |
21:17 | <@Derakon> | That way I can do "SDL_Surface* playerSurface = loadBitmap('images/player.bmp');" |
21:18 | <@Derakon> | Instead of having to do "SDL_Surface* playerSurface; loadBitmap(playerSurface, 'images/player.bmp');" |
21:19 | <@Derakon> | As a general rule, I don't like functions to modify the arguments I pass to them unless there's a good reason to (generally because the return value of the function is needed for something else and the language doesn't support returning multiple values). But this function is void when it could be non-void. |
21:21 | <@AnnoDomini> | http://pastie.org/425832 <- This? |
21:21 | <@Derakon> | Yes. |
21:22 | <@Derakon> | I believe McM mentioned in passing that it is possible for DisplayFormat to fail, though; you should check that (check the docs, and if it is possible, check to see if you fail). |
21:22 | <@AnnoDomini> | I'm worried about memory leaks or something. |
21:22 | <@Derakon> | What would cause memory leaks? |
21:23 | <@AnnoDomini> | I'm not sure. |
21:23 | <@AnnoDomini> | They're mentioned in DisplayFormat's page. |
21:24 | <@AnnoDomini> | The API doesn't speak of them failing for any reason, but they imply that it can fail. |
21:24 | <@Derakon> | Okay, the memory leaks described would be due to the following code: "SDL_Surface* surface = SDL_LoadBMP('images/player.bmp'); surface = SDL_DisplayFormat(surface); return surface;" |
21:25 | <@Derakon> | This is a leak because the surface created by LoadBMP is still hanging around, but with no references to it. |
21:26 | <@AnnoDomini> | http://pastie.org/425836 <- Yet another pastie. |
21:27 | <@Derakon> | Better. |
21:27 | <@Derakon> | "!(image == NULL)" would be better written as "image != NULL" though. |
21:28 | <@McMartin> | You can also, because this is C and/or C++, just say "if (image)" |
21:29 | <@McMartin> | But in these modern days I'm inclined to call that one a bad habit. |
21:30 | <@AnnoDomini> | It's pestering me about reaching the end of a non-void function... can I just put return 1; at the end? |
21:31 | <@Derakon> | Actually, just nix the "else{}" and unindent your last error condition. |
21:31 | <@Derakon> | Or alternatively, swap the 'if' and 'else' blocks and unindent. |
21:32 | <@Derakon> | Basically, your options are: "if image is not null, then return success; (implicit else) fail" and "if image is null, then fail; (implicit else) return success". |
21:32 | <@AnnoDomini> | http://pastie.org/425846 <- This? |
21:33 | <@Derakon> | Looks good! |
21:34 | <@AnnoDomini> | Now to actually make the stuff in the main file. I'm thinking, as mentioned, of making an array: tiles[NROF_TILE_TYPES]; |
21:34 | <@AnnoDomini> | Er, SDL_Surface* tiles[NROF_TILE_TYPES]; |
21:36 | | * Derakon ponders mapgen. |
21:37 | <@Derakon> | I've been doing modeling for too long; I need to get some coding in before I completely lose my productivity. |
21:37 | <@Derakon> | So I'm thinking I might want to make my first room feature, which I'm thinking will be a labyrinth. |
21:37 | <@Derakon> | Anyone know of any good maze-making algorithms? |
21:37 | <@McMartin> | Nethack's isn't bad. |
21:38 | <@McMartin> | There's a screensaver that does one too. |
21:38 | <@AnnoDomini> | http://i43.tinypic.com/8xn6kz.jpg <- So far it looks like this. |
21:38 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has quit [Connection reset by peer] |
21:39 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has joined #code |
21:39 | | mode/#code [+o Attilla] by ChanServ |
21:39 | | * Derakon snerks at the status display. |
21:39 | <@McMartin> | BY THE SURLY BEARD OF MRIFK |
21:39 | <@McMartin> | (Also, "By Crom, there will be pixels spilt today!") |
21:41 | <@AnnoDomini> | Given lack of outrage, I assume that making an array of pointers is not horrible. |
21:41 | <@McMartin> | In C, it's actually the only way to get multidimensional arrays. |
21:42 | <@McMartin> | C++ lets you go all java-y and end up with some things that are actually unnervingly close to garbage collection with them too |
21:44 | <@McMartin> | You'd either have to spend a lot of time with custom deallocators, which is Bad Times, or use a C++ wrapper around the whole library, though, so I don't recommend it here. |
21:46 | <@AnnoDomini> | So, er, I have to do FreeSurface on every damn thing in this array of mine at exit? |
21:47 | <@AnnoDomini> | Is there a better way of doing this? |
21:48 | <@ToxicFrog> | What's the Python string concatenation operator? |
21:48 | <@AnnoDomini> | It sounds really bad, since I have shutdown()s littered everywhere, and I don't really want to include specific code in the general shutdown function. |
21:49 | <@McMartin> | TF: + |
21:49 | <@McMartin> | AD: In theory the OS will clean up everything left over at exit |
21:49 | <@McMartin> | In practice this is even usually true |
21:50 | <@McMartin> | If you want to be picky about it, the best way to do it is not to atexit each destructor, but instead to have a single function that will systematically wind down everything and have that be atexit()ed. |
21:50 | <@Derakon> | AnnoDomini: this is why many of us prefer to use languages with built-in garbage collectors. |
21:51 | <@Derakon> | (Which does not prevent memory leaks, but makes them vastly harder to create) |
21:58 | | * Derakon eyes http://www.astrolog.org/labyrnth/algrithm.htm |
21:58 | <@Derakon> | Main problem here is that it talks about walls and spaces as having different sizes (walls being infinitely thin), while my walls have thickness. |
22:01 | < Rhamphoryncus> | ToxicFrog: keep in mind repeated concatenation should be done by building a list, then using ''.join(mylist) |
22:01 | <@AnnoDomini> | Yay! It works. |
22:01 | <@ToxicFrog> | Rhamphoryncus: yeah, this is just thing = "constant" + argument + "another constant"; do_stuff(thing) |
22:02 | < Rhamphoryncus> | ToxicFrog: *nod* that's fine. You may want to consider string formatting though |
22:02 | < Rhamphoryncus> | thing = "constant %s another constant" % argument |
22:08 | <@AnnoDomini> | Now I might try to figure out how to make it so the thing only draws the screen on player action-input. As it is, it refreshes every 20 ms or so. |
22:09 | <@Derakon> | Sleep, check for input, if input given, react to input and draw, repeat. |
22:10 | | * AnnoDomini really likes the concept of that struct that keeps information on WTF is going on. |
22:15 | <@AnnoDomini> | It works, too. |
22:16 | <@AnnoDomini> | Game checks for input every 20ms, but redraws only when the input demands it. |
22:16 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has quit [Connection reset by peer] |
22:17 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has joined #code |
22:17 | | mode/#code [+o Attilla] by ChanServ |
22:18 | | Reiv [~82d94c4d@Nightstar-29731.dsl.in-addr.zen.co.uk] has joined #Code |
22:20 | <@Derakon> | Oooh, recursive division should work well for my purposes. |
22:21 | < Reiv> | McMartin! |
22:23 | | * Reiv hunts. |
22:25 | | * AnnoDomini ponders how to make a textbox. |
22:25 | <@AnnoDomini> | It shouldn't be too hard, if I get past wrangling strings. |
22:26 | <@AnnoDomini> | I'm quite pleasantly surprised that the font is a square. |
22:26 | <@McMartin> | Reiv: Hm? |
22:27 | <@McMartin> | AD: Not too bad, as long as you don't try to implement a cursor too |
22:28 | <@ToxicFrog> | AnnoDomini: SDL_gfx text drawing routines? |
22:28 | <@ToxicFrog> | Yeah, it's handy. |
22:28 | <@McMartin> | I think he meant *entering* text |
22:28 | <@ToxicFrog> | I meant for the square font. |
22:29 | <@AnnoDomini> | No, no, I mean displaying text. |
22:29 | <@McMartin> | Oh. Yeah, that's cake if you've got SDL_gfx |
22:30 | <@AnnoDomini> | Rather than gnawing at it with StringColor directly, I want to designate an area "this is for text" and be able to .setText(char*) and .appendText(char*) and whatever. |
22:30 | <@AnnoDomini> | Without having to worry too much that the text is out of bounds. |
22:31 | < Reiv> | McM: You challenged me to make a structure that reversed the order of a list in Haskell |
22:32 | <@AnnoDomini> | I fear I will need to make it a class. |
22:32 | <@McMartin> | Aha, so I did. |
22:33 | <@McMartin> | AD: You may find it somewhat easier to use std::strings internally and only go to C-strings when you have to talk to SDL directly |
22:34 | <@McMartin> | Since you can do + for concatenation and they manage their own internal storage and all. |
22:37 | < Reiv> | urgh |
22:37 | < Reiv> | op me? |
22:38 | | mode/#code [+o Reiv] by McMartin |
22:38 | <@Reiv> | http://paste.ubuntu.com/137059/ |
22:38 | <@Reiv> | danke |
22:38 | <@Reiv> | (I do not regret having that mode in this channel. Even if it's occasionally inconvinient~) |
22:38 | <@McMartin> | That'll do it all right. |
22:38 | <@Reiv> | Woo! |
22:39 | <@McMartin> | There's a highly efficient way of doing it, though. |
22:39 | <@McMartin> | (When I predicted you wouldn't solve it, I had forgotten that Haskell had a concat operator~) |
22:39 | <@McMartin> | It's 3:30 PM here and I'm in the middle of my workday, but this will make a handy segue later on for discussing iteration and tail recursion |
22:40 | <@ToxicFrog> | Woooooo tail recursion |
22:40 | <@Reiv> | hm |
22:41 | <@Reiv> | Oh yes, concat is by its nature linear time... which means my recursion is n^2. Whoops. |
22:41 | | * Reiv thinks. |
22:41 | <@Reiv> | Taking the head off is a constant time. Hum. |
22:42 | <@McMartin> | The : operator is also constant time. |
22:43 | <@McMartin> | And, spoiler: The function that does the work is allowed to have extra arguments |
22:43 | <@Reiv> | hm |
22:43 | <@McMartin> | That is, you don't have to have it be "reverse x"; it can be "reverse x (other arguments)" |
22:43 | <@Reiv> | ... hm |
22:43 | <@McMartin> | (Since you can then do scoping tricks to let you get "reverse x" back later) |
22:44 | | GeekSoldier [~Rob@Nightstar-8573.midstate.ip.cablemo.net] has joined #code |
22:44 | | mode/#code [+o GeekSoldier] by ChanServ |
22:46 | <@ToxicFrog> | I know this one, but I don't remember the syntax :( |
22:48 | <@McMartin> | The part that's awesome about it is that despite being recursive, it ends up running in constant *space*. |
22:49 | <@McMartin> | Which is actually impossible in the ABI used by basically all compilers for traditional languages. |
22:49 | <@McMartin> | (* except assemblers, where there's a peephole optimization that does it) |
23:01 | | * AnnoDomini thinks he'll stay up another hour. |
23:04 | <@Reiv> | ... sidenote: |
23:05 | <@Reiv> | What is the value of (2 *) |
23:05 | <@Reiv> | It's... a function. But functions have values. But is the functions value the function itself? |
23:05 | <@ToxicFrog> | A function with type (Number => Number), I think. |
23:05 | <@ToxicFrog> | What do you mean by "but functions have values"? |
23:06 | <@Reiv> | Functions in Haskell have values. |
23:06 | <@ToxicFrog> | What do you mean by "have values" here? |
23:06 | <@Reiv> | Although I admit I am rather hazy as to how this actually /works/, but |
23:06 | <@ToxicFrog> | They are values |
23:07 | <@Reiv> | ... okay? |
23:07 | <@ToxicFrog> | They have types, and possibly things like upvalues and environments although I'm a bit hazy on the details |
23:07 | <@ToxicFrog> | They evaluate to values when applied to inputs |
23:07 | <@ToxicFrog> | But I honestly cannot understand the statement "they have values" |
23:08 | <@ToxicFrog> | I'm not trying to be snarky here, it just doesn't make sense to me. |
23:08 | <@ToxicFrog> | So can you rephrase? |
23:09 | <@Reiv> | I may have misworded. |
23:09 | <@Reiv> | Functions, as you say, /are/ values, okay |
23:09 | <@Reiv> | Accordingly, "What is the value of (2 *) ?" - question from my textbook I am honestly baffled by |
23:10 | <@ToxicFrog> | "a function with type (Num => Num)", if I remember correctly, but ask ghci. |
23:12 | <@ToxicFrog> | (also, your textbook uses Haskell? Rock.) |
23:12 | <@AnnoDomini> | Reiv: It's a zen riddle. |
23:12 | <@Reiv> | (It is in fact a Haskell Textbook, but yes~) |
23:12 | <@AnnoDomini> | Once you understand that the question is the answer, you will achieve enlightenment. |
23:12 | <@AnnoDomini> | Ommmmmm. |
23:13 | | * Reiv shoots AnnoDomini with a monkey wrench, carries on |
23:13 | <@AnnoDomini> | BTW, how's your half-ork do with an extra 44 lb. of weight? |
23:14 | <@McMartin> | I believe they want "(2*) is equivalent to \x -> 2 * x" |
23:15 | <@McMartin> | And the type signature there would be Num a => a -> a |
23:15 | <@Derakon> | foo[:-2] is the last two elements of foo, right? |
23:15 | <@Reiv> | Anno: Medium load. In a sack for ease of dropping. |
23:15 | | * Reiv thinks. |
23:17 | <@Derakon> | Oh, wait, I want foo[-2:], not foo[:-2]. |
23:18 | | Reivles [~82d94c4d@Nightstar-29731.dsl.in-addr.zen.co.uk] has joined #Code |
23:18 | < Reivles> | Damn thing |
23:19 | < Reivles> | I saw the bit on \x -> x * 2 and that was it |
23:19 | < Reivles> | ... okay what |
23:20 | <@AnnoDomini> | http://pastie.org/426001 <- How's this look? |
23:20 | < Reivles> | "draw a picture (using boxes for elements and arrows to show ordering) of the list naturals." |
23:20 | < Reivles> | ... draw a picture huh? |
23:20 | | Reiv [~82d94c4d@Nightstar-29731.dsl.in-addr.zen.co.uk] has quit [Quit: CGI:IRC (Ping timeout)] |
23:20 | < Reivles> | I'm *reasonably* certain that it's not asking me to fire up SimpleGraphics... |
23:21 | < Reivles> | (naturals = [1,2..] ) |
23:22 | < Reivles> | I get the feeling this would be straightforward, except I don't understand the question. |
23:23 | <@Derakon> | First, highly flawed pass at mazes: http://derakon.dyndns.org/~chriswei/games/jbrl/maze/1.png |
23:25 | <@ToxicFrog> | Reivles: draw, as in on paper or in the GIMP, a diagram of the way the list 'naturals' is constructed |
23:25 | < Reivles> | ...oh! |
23:25 | < Reivles> | hm. |
23:27 | < Reivles> | Is it meaning [1] -> [2] -> [3], or something a little more technical? |
23:27 | <@ToxicFrog> | I think just that, but don't quote me on that. |
23:29 | | Vornicus [Vornicus@Admin.Nightstar.Net] has joined #code |
23:29 | | mode/#code [+o Vornicus] by ChanServ |
23:30 | | * Derakon hands Vorn a maze. |
23:30 | | * Vornicus follows the right wall until he either loops or finds the exit. |
23:31 | | * Derakon hands Vorn a maze with shifting walls. |
23:31 | | * AnnoDomini ponders substrings. |
23:31 | | * Vornicus cry. |
23:32 | <@AnnoDomini> | How do you concatenate strings? With +? |
23:32 | <@AnnoDomini> | (In C++, using strings, not c-strings.) |
23:32 | <@Derakon> | + or . depending on language, as a general rule. |
23:34 | <@AnnoDomini> | Can I go str = ""; to empty a string? |
23:34 | <@Derakon> | Yes. |
23:34 | <@ToxicFrog> | Derakon: using C++ STL strings? |
23:35 | <@Derakon> | Ask AD, not me. ¬.¬ |
23:35 | <@ToxicFrog> | ... |
23:36 | <@AnnoDomini> | I'm getting questions redirected to me about C++. Crystal Dragon Jesus help us all. |
23:36 | <@AnnoDomini> | :P |
23:36 | <@ToxicFrog> | http://cplusplus.com/reference/string/string/operator=.html |
23:37 | <@ToxicFrog> | Looks like the answer is indeed yes. |
23:37 | <@Derakon> | I assumed TF was asking me if I was using STL-style strings or not. I'm using Python. |
23:37 | <@ToxicFrog> | Also, use this site. |
23:37 | <@ToxicFrog> | Derakon: I was asking you if you can really get away with that in STL strings. |
23:37 | <@Derakon> | Ahh. |
23:37 | <@AnnoDomini> | I am, but there's much information there, and it's sometimes hard to find what I need. |
23:38 | <@ToxicFrog> | And as it happens you can, because they overload =. |
23:39 | <@Vornicus> | Which is the kind of shit you can only do in a statically typed language, and it gives me the willies. |
23:39 | <@AnnoDomini> | 7 of 9 functions defined in the header, and one of the remaining ones is the constructor. Now for the point of the class, which is the draw() method. |
23:40 | <@McMartin> | And yes, you can use = on C++ strings. There is also some kind of clear method too, I think, but meh. |
23:45 | <@gnolam> | 7 of 9 functions? "wearTightOutfit()"? "failToUnderstandHumanEmotion()"? |
23:45 | < Reivles> | Win! |
23:46 | <@AnnoDomini> | I was waiting for someone to make a joke. |
23:47 | < Reivles> | Okay, hm |
23:47 | | * AnnoDomini lols at Nurias' sign, complete with authentic spelling mistakes. :D |
23:50 | < Reivles> | Ahyep |
23:50 | < Reivles> | It's common. He's not fond of it. |
23:50 | | * Thalass flop |
23:50 | <@gnolam> | AnnoDomini: ? |
23:51 | <@AnnoDomini> | I'm talking of Reiver's post in a PbP DnD game we're both in. |
23:52 | < Reivles> | I just posted a rough sketch of the sign outside my dorfs workshop. It has spelling errors, 'cuz it's a language he detests. :p |
23:53 | < Reivles> | Aaanyhow |
23:53 | < Reivles> | ... hah. Final question in my assignment requires me to do an excersize out of my book. Well, then. |
23:53 | < Reivles> | Good thing I'm working through by book anyway~ |
23:59 | | * AnnoDomini scratches head. Seems to remember str.substr().c_str() will work. |
--- Log closed Wed Mar 25 00:00:39 2009 |