C and text mode

qrleon's picture

So, Cymon's games has inspired me to try my hand at textmode games. I will write throwaway test programs and hopefully work towards something interesting.

Throwaway Test program 1: It's a start, I guess. You can move around a boring room and talk to a single NPC (and harass him, if you try hard enough). You can also edit the board by pressing forward slash, and load/save the board to a text file.

The next one will have an actual game objective! And win/lose states! what the hell am i doing

AttachmentSize
textmode_throwaway_test_program_1.zip64.64 KB

Comments

SpindleyQ's picture

Oh HELL YES. This is

Oh HELL YES. This is inspiring. I need to step up MarMOTS development if I'm going to compete with this.

I'd love to sneak a look at the source code. I've poked at curses a couple of times but never really got anywhere.

qrleon's picture

Sauce code

Here. It's all crammed into one messy file, editing/playing functions are inter-mixed, no malloc() ... things I want to correct next time.

AttachmentSize
source_throwaway_test_program_1.zip4.88 KB
qrleon's picture

Throwaway app 2 will be a

Throwaway app 2 will be a sort of platformer.

Wasted yesterday trying to find out if PDCurses can show the additional IBM glyphs (Because Code Page 437 is inherently funny), and attempting to get some things like init_color() and color_content() to work. I should have just focused on making a game...

All the AAAAAA's of the rainbow:

To use colours, you have to initialize foreground/background pairs. Small problem: the leftmost A's are too bright (they are supposed to be black-on-black and darkgrey-on-black).

AttachmentSize
AAAAAAscii.png2.99 KB
qrleon's picture

Wasted more time on stupid

Wasted more time on stupid crap yesterday. Couldn't get malloc() or free() to work properly. Switched back to #defined array dimensions.

I don't have a board-loading function or a level editor yet, but the player will eventually hop around like this (instantaneous, no animation):


   .....
   @   .
&&&&   &&&&
&&&&   &&&&
&&&&&&&&&

        ...
        . .
        . .
        @ .
&&&&&&&&& .
&&&&&&&&& .
&&&&&&&&& .
&&&&&&&&&&&&&&&&&&&

The game will be about eating sandwiches. dropping too far will cause butt damage. Starvation, touching mines, or fatal butt damage will take a life. Each sandwich increases the distance of your jumps. I'm thinking ... 9 levels. Here's a WIP, mainly to prove to myself that I can keep doing a thing for a while without shelving it.

controls are on the numpad: 1 and 2 to walk, 46789 do various jumps.

AttachmentSize
c_textmode_b_WIP.zip73.95 KB
SpindleyQ's picture

I'm really digging the

I'm really digging the instantaneous jumping. When I saw your diagrams, I had no idea how it would work, but of course drawing the jump trail on the screen makes perfect sense.

qrleon's picture

anoter wip

The programming is finished for the most part. An ending check is broken, but everything is in place except for level content. I have no idea what to do for levels, but slapping the program together was good practice. Before this, I had never written more than a few lines of C.

AttachmentSize
textmode_foolin_2_one more WIP.zip71.64 KB

This is really pretty cool!

This is really pretty cool! :)

I could see it turning into some sort of tactical / rpg /platformer hybrid. xD

dessgeega's picture

this reminds me of the game

this reminds me of the game with no name.

(not the ds one.)

qrleon's picture

I tried to play that a while

I tried to play that a while ago, during the time when computers were too fast for old games and before DOSBox was omnipresent. I still have no idea what the correct speed is.

It's good when passwords are actual words. Today's password is sequencer

Speaking of old texty stuff, I'd like to make something like Castle Adventure.

qrleon's picture

malloc() was crashing

malloc() was crashing because I wasn't casting the pointer correctly(?). Seems okay now.

Does this crash when you exit (either by clicking the close button or pressing q)? That's what happened before.

AttachmentSize
textmode_this_is_so_dum.zip61.53 KB
SpindleyQ's picture

malloc

I was an embedded C programmer in a former life. Your problem is almost certainly memory corruption -- likely writing to already freed memory, but possibly also writing past the end of allocated memory (off-by-one array allocation, for example) -- and is probably still lurking. A bad cast would have to be bad enough to mangle the pointer somehow so that even _reading_ from that address would cause a segfault.

Attach or PM me the source, I'll find your bug.

qrleon's picture

VERY GENEROUS OF YOU

The crash was in an older version of the jumping game that I no longer have, wherein I tried to allocate 2D arrays. Specifically, the Microsoft apology box appeared when I tried to free the arrays.

Knowing me, I probably borked something in this program, too.

AttachmentSize
OLD_JOEY_CONVENTION_source.zip953 bytes
qrleon's picture

here is the source for the

here is the source for the jumping game, with allocation re-added. the allocation/freeing is around line 206

AttachmentSize
textmode_b_inspection.zip72.89 KB
SpindleyQ's picture

I don't see anything wrong

I don't see anything wrong with the first program.

As for the second program, some random thoughts:
- As written, there's no need to use malloc at all; saying "int map[SCREEN_Y][SCREEN_X];" and "int mapStore[MAX_STORED_MAPS][SCREEN_Y][SCREEN_X];" would work just as well.
- There's no reason to free a pointer that you know is null. ("if (x == null) { free (x); return 1; }" can become "if (x == null) return 1;")
- Rather than doing checks every time you access your map with coordinates that might be out of bounds and inevitably missing some places, write a function to do it for you and return A_WALL if the coordinates are invalid. (For an example of where this might be handy, run your game in a debugger, get to level 2, hit 0 before moving, and see where it crashes :)
- Maybe do something like, "typedef int[SCREEN_Y][SCREEN_X] map_t;"? "int ***" is a scary type, man. Then you could have the number of maps saved in boards.txt, and allocate mapStore with "malloc(sizeof(map_t) * nMaps)".

I'm not seeing any places where you're writing over the bounds of map or mapStore; you're mostly doing bulk copies rather than realtime map manipulation and so the potential for error is small, and if you DID mess that up, it would probably show up in other ways (sideways levels if you swapped SCREEN_Y for SCREEN_X in one of your loops, say). I haven't gotten it to crash on exit, so good show there.

Level 4 is mean, but also kind of awesome.

qrleon's picture

Thank you for inspecting my noob code.

Quote:
(For an example of where this might be handy, run your game in a debugger, get to level 2, hit 0 before moving, and see where it crashes :)

:O

also, yes you are absolutely right, int *** is scary as hell

qrleon's picture

getting there

Added a collision/bounds checking function, removed malloc of map arrays

On second thought, starving to death sucks. I will replace it with a turns counter. Health seems pretty redundant too, since to do any interesting levels I need to keep feeding the @ sandwiches to increase its jumping distance -- damage is inevitable.

I need to make three more screens.

qrleon's picture

changed the jump guide so

changed the jump guide so that it doesn't obscure the mines and sandwiches

I think that's about it.

AttachmentSize
Sandwich Hopper.zip77.44 KB
qrleon's picture

what i doesing

I feel like making something along the lines of Castle Adventure

Q: What is a Castle Adventure?

A: Well, (leaning on a tree stump), it's a mysterious text-based oddity from 1984. You're trapped in an old castle, and the only way to open the front gate is to steal treasure (at least I think that's what you do). All areas are persistent and combat plays out in real time. You can also type in basic verb-noun pairs to make your character do stuff. Your health is mysteriously never shown to you.

Mysterious!

...

I think I will avoid real-time combat, and forego verb input for situation-specific hotkeys. Basically I just want to make a short adventure game, but whenever you do something in text mode you have to explicitly say that it's not a roguelike.

*** NOT A ROGUELIKE ***

I need ideas for the setting and plot, though. might stew on it for a while. The easy solution would be to make it a "trample through a wacky house" game, but I already drove that into the ground in ZZT. Maybe Area 51? Or something along the lines of the Lone Ranger.

qrleon's picture

Working on an ascii artboard

Working on an ascii artboard editor/viewer (for the game mentioned above).

I miss the other cursors frantically drawing stuff in MarMOTS. My artboard is 500% lonelier.

SpindleyQ's picture

It's one of my missions this

It's one of my missions this week to get MarMOTS back online. I was up until 1am last night squishing bugs in my persistence code.

qrleon's picture

I haven't posted much

I haven't posted much lately. Forgive me, komrades!

I completely forgot about the PDCurses adventure and instead futzed around with SDL. I don't have much to show for it, just a simple tilemap editor and an ultra-basic platformer walkabout demo. I'd like to get collision detection working, but I need to be able to load tilemaps into the walkabout blah blah blah I should make a KNP game.

AttachmentSize
qrltiles.png11.59 KB
dessgeega's picture

you've abandoned text mode

you've abandoned text mode but not the happy garishness of old dos games

make more games qrleon

Pizza Time's picture

Those were the daaayyyyss

This makes me think back to the times of school computers and DOS shareware games menus.

SpindleyQ's picture

This looks gorgeous. I

This looks gorgeous. I adore the idea of extending the 4-colour CGA palette by changing the brightness, rather than adding different colours.

Pizza Time's picture

4reelz

It looks totally legit too.

qrleon's picture

The graphics were from an

The graphics were from an old mockup that was intended to look like a super-gaudy DOS EGA game. I planned it as a nonlinear maze platformer, but if I made it now, it would be a straight shooter.

the whole mockup if you're curious

AttachmentSize
egaman_mockup.png18.09 KB
Pizza Time's picture

Fabulous!

Fabulous!

radix's picture

Tubular!

Tubular!

dessgeega's picture

rhinoceros

rhinoceros

Strong's picture

pretty dang neat

pretty dang neat

qrleon's picture

Thanks

I have two platformer ideas at the moment, one I'm super excited about and one that is lazier but would be easier to build. These pics are from the latter; I'm not fit to make the other one yet. A high framerate, vsync, and smooth scrolling are prerequisites... this one should be okay @ 30 frames per second with no scrolling.

qrleon's picture

im slow progremmer

The screen editor has almost everything I want, except for copy/paste/import/export, and some hotkeys for certain tiles. Very similar to ZZT, I guess.

Still no actual game engine. :-)

AttachmentSize
qrl_map_dix.png15.57 KB
qrleon's picture

Got inspired enough this

Got inspired enough this evening to finish the map program. My implementation of layers was bad, and I had to write some lame repetitive code to make it all work.

AttachmentSize
qrl_sdl_progress_maybe.png23.97 KB
qrleon's picture

I finally have a "walk

I finally have a "walk around an empty room" mockup.

Enclosed is a Windows binary. Let me know if it explodes.

S: jump
A: shoot
Hold S: charge
A + S: float

AttachmentSize
qrl_egaman_walkabout.zip157.45 KB
Blueberry Soft's picture

It exploded!

I think it game me a blue screen, then my computer reset. This is in Vista, before I saw the program open. There were other things running, so I'll re-try when I get the balls.

qrleon's picture

Damn, I wonder what could

Damn, I wonder what could have caused a blue screen? I hope you didn't lose important stuff :(

SpindleyQ's picture

Works fine for me in Vista!

Works fine for me in Vista! Solid physics. I'm digging the floating mechanics.

Blueberry Soft's picture

D:

It happened again. The program started, the sprite dropped don, and when it touched the ground: Blue Screen. It was up for a while, but I couldn't tell what the actual problem was.
Didn't lose anything, either time.

qrleon's picture

Shit...

I don't have Vista, so I can't test it. Sorry for the crashes dude/dudette, I really hate blue screens. If you can run KNP, here's a mockup from a while ago (with a couple of extra things).

Also, what are your system's specs, just out of curiosity? 32 or 64 bit? multiple cores? do you have a video card, or integrated graphics?

AttachmentSize
knp_egaman.zip171.72 KB
Blueberry Soft's picture

System specs:

Acer Extensa 5210
Celeron M 520 1.60 GHz
1GB RAM
Integrated Graphics (Mobile Intel 945 Express)
Windows Vista Home Basic
32 bit

Excuse me if any of that's a bit wacky. I haven't been clued into computers for 10 years.

Let me know if you need anything more specific. There is a crash log, just not sure how to show you it / what of it to show you.

SpindleyQ's picture

That's kind of insane. A

That's kind of insane. A regular ol' C program really shouldn't be able to bluescreen a Vista machine. If I had to guess, I'd say there's some kind of video card driver bug at work.

qrleon, as always, I'm happy to look at your source code for memory corruption bugs, if you'd like the help.