Adventures in Programming – coding

Ok, this isn’t what you expect from yer humble blogger, but it’s on my mind and it’s what you’re getting, so here we go.

I’ve been helping my son write a simple adventure game, and I figured it might be fun for any other parents looking for ways to write an adventure game in Python.

I used to write adventure games in Amstrad Basic, so I’m trying to apply all the knowledge I learnt there here, so let’s start with some basics. I like to draw a map…

This, very crude map, is required for a couple of reasons, every room here needs a unique number so that we can, for example, say in room 2 if we go west we arrive at room 3.

The map can be anything (we decided on a haunted mansion, you could draw a different map and call it a space ship or a dungeons and dragons type dungeon)

Python has a few ways we can use to encode this, I went with the simplest which was a very simple list – a list is a collection of things, can be a collection of numbers [1,2,3,5] or strings (ie text) [“alpha”,”beta”,”gamma”,”delta delta delta”] or a list of LISTS (mindblowing, I know) [ [1,2,3], [4,5,6], [7,8,9] ]

You can access any element in a list by referring to its index – so say we call our list numbers and it contains [15,16,17,20,50] then we can refer to the first item on the list by looking at item 0 (lists start from 0 going up) numbers[0] = 15, numbers[3]=20

So for an adventure game we’re going to use a list of lists – keeping a super rigerous structure means we can always refer to things in it that will work.

Python has a special keyword “None” which means … well, it literally means nothing. Sometimes we need to refer to Nothing.

We’re going to create a list of rooms, and this list of rooms will have, in every element some data about the room. Because I drew the map with room 1, I’m going to set room zero as a None list (if I was a good programmer, I’d go back and create a room zero, but for reasons that might become apparent the Number 0 and the word None can both mean the same thing, so best to avoid any possibility of a room zero)

Each room will have the following information: a title, a description and a set of exits – north, south, east and west. If the room doesn’t have an exit in a particular direction we specify the direction as None

rooms =[

[“Entrance”,”The main entrance to an old mansion. It looks dilapidated, old paintings hang on the walls looking as tired as everything else”,None,2,None,None],

[“Base of the Stairs”,”Standing at the base of the stairwell, it looks too dangerous to climb. Though there does appear to be an exit below it, to the south and a door that looks like it opens to an overgrown jungle is to the west.”, 2,7,3,None],

(and so on)

]

I then set up a variable containing the current room number (just called room)

room = 1

And now if we wanted to see our current location, rooms[room][0] would be the title of the current room. Movement is simply a matter of altering the value of room (going South from Room 1 is simply a matter of setting room=2)

Next we want to create a simple loop that displays the current location, displays any directions we can go in and then asks the user what they want to do.

(Python, by the way, is a bloody stickler for where spaces and indents are allowed, talk about yer grammar nazis)

Out loop can look like this:

alive=True # the has here means anything after the hash is a comment, so this is a comment.

while alive: # we keep doing this block (everything below the while) until the variable alive becomes False (which on this basis it never will)

#python needs any block to have an indent…

print(rooms[room][0]) #print title

print(rooms[room][1])#print description

if rooms[room][2]: print(“You can go North”)

if rooms[room][3]: print(“You can go South”) #etc, you can figure out the rest..

command = input(“What now?”)

And I’ll leave it there. What was fun about this exercise is showing Nathan how each small thing can do something different – showing him how to print “You can go North” he was able to figure out “You can go South” etc.

The next big thing is to break the command down in to a bunch of words and interpret those words so we can travel to locations. Python, it turns out, is pretty handy for splitting words up, so we did this:

command = command.lower() #converts the text in command to lowercase.

words = command.split() # split the command into a list of words, splitting where ever there’s a space

# and now we check movement.

if words[1] == “north” and rooms[room][2]:

# user has typed North and we’re able to go north…

room = rooms[room][2] # so we go north, by moving to the room that is north of the current room

Again, knowing how to go North, and with a bit of prompting, Nathan was able to extrapolate how to go South and West and suddenly we had a walking adventure.

Next big bits were to add objects and let the user lift things as well as do stuff (we added a key which you could use to open a chest of drawers to find a diary) we’ve also got to add some monsters and a combat system, but that remains a future exercise.

Anyway, apologies if this is dull – but it’s your own fault for reading this far. Some of the code above may not work exactly (I’m typing it in to wordpress so syntax errors are sneaking in) but it should be a good starting point if you have python or pythonista on the ipad and want to help an adventure loving kid to start program their own adventure game.

Adventures in Programming

When I was 14 years old, my brother (then 13) and I received a joint birthday/Christmas present – this was not-uncommon. His birthday was 2 days before Christmas, my 3 days after, and we were one year apart (Mark passed away in 1997, if you’re wondering why this is all past tense). In 1994, my mum bought us an Amstrad CPC464 with a green screen, which, if memory serves, were about £399.

I fell in love.

Mark, ended up with the shittier end of the deal though, not fussed on computers (though he liked games) mum and dad ended up getting him a different present. The computer quickly became mine.

Every minute spent with my Amstrad was a delight, the noise of the tape deck and its bizarre mix of tones as it loaded programs, the clack of the mighty keys (hewn from the toughest of plastics, mined down Alan Suger’s working man’s silicon valley pits) and the glowing green screen – literally casting a sickly green spell over me. Decades before the matrix, I knew what it was like to be a lone hacker tapping on green screen console and hoping the universe was more exciting.

And the thing was, it could be.

Buying and playing games was boring, sitting in front of the screen keying in computer listings that allowed you to fly planes dropping bombs on an undefined enemy, to throw bananas at a monkey across the sky or collect squares as a snake all built line by hard won line over several evenings thanks to the back of magazines like Amstrad Computer User and Amstrad Magazine was living in the future.

It set me up for the rest of my life. Later that year, I took a one week job placement for school and found myself there for the next 15 years or so, doing tech support, writing software and sometimes selling computers. It also let me keep connected to comics in a period when I’d let peer pressure convince me comics where for kids, I’d still pick up Computer and Video Games PURELY for the work of Jerry Paris, one of the greatest unsong british comic artists that ever sloshed ink across a page. (Jerry and I are now friends, so that’s come into a lovely full circle).

Anyway, one of the main things I did with my Amstrad was write adventure games. I was obsessed. I fooled myself in to thinking I liked the ability to create mad, wild adventures that could go anywhere or do anything, but really … really… I loved the absolute control I had over the world. I could make the computer do all sorts of things and I could push it in fun, unsurprising ways.

The Amstrad didn’t have much memory, so one of my first little innovations was to create a very basic compression – it was crude, but it worked (how crude? Any letter of the alphabet that was followed by a space would have its ASCII number increased by 64, the space then would be deleted – this let me remove all spaces from a bit of text for storage – I mean it wasn’t neccessary at all for the tiny adventures I’d write, but I thought I was pretty clever for it).

I enjoyed taking the computers rigid data and turning it in to text. Taking an extant adventure game which would tell you, brusquely “You can go: NORTH, SOUTH” and turning it into an adventure with a little more finesse, so it became “You can go North or South” (cleverer than it seems)

My oldest son is now 13, he’s lived his entire life with at least three or four computer’s within easy reach. He’s done a little programming, in scratch, but lately he’s expressed an interest in doing something in python – it’s not a language I’m familiar with, but I figured, why don’t we write an adventure game together. So that’s what we’ve been doing.

And it’s fun.

How do you know when you’re done…

And I mean with a website. Or social media.

I was here for the alt.newsgroup revolutions, I gophered my way across universities and the world, I studiously avoided myspace until it was murdoch’s space and I never quite reunited with my friends.

Facebook came and went, and I joined in, but now it’s running free without me, and weirdly, my life isn’t lacking anything. Or if it is, I’m unaware of it.

RSS feeds – remember those? seemed like a brilliant bright star whose genius would shine forever, then google bought up the biggest collator of rss feeds and then killed it stone dead.

But twitter. Man, I loved twitter.

Back when twitter was a place to just hang out and tell stupid jokes and make up nonsense. I tweeted my way through the Bonekickers tv series, I made friends on twitter, I got work through twitter and I’ve enjoyed it for a large part of the past decade or more.

But maybe its time is gone. Could be every internet phenomena has a finite life – there’s no reason that just because a thing becomes so insinuated into the everyday fabric of real life that it can’t just disappear tomorrow (vines, remember vines?)

I found myself quoted in an article about twitter my tweet was the dangers of bad jokes being taken out of context and weaponised in this new internet flash mob world (remember flash mobs? are they still a thing?) which feels like the last meta nail in the digital coffin of what twitter used to be.

I’m trying to figure out a way to see if I can’t still enjoy the many many benefits of twitter, but maybe… maybe it’s a relationship that’s long past saving and, right now, the only thing keeping me on there is the deeply sunk cost of building a reputation on the site over the past 12 years.

Final note: I AM a coward. So I won’t be deleting twitter. I am trying to figure out a way to delete my entire history and start broadcasting simply art and updates on twitter. Saving stupid thinking for a notebook or some other way to capture that stuff that isn’t exposed to the entire world.

Writing has stalled

After getting to week 7 of the Couch to 80k writing challenge, I balked out of the last week, exhibiting a pattern of behaviour which I can only describe as “mission nearly accomplished”.

Week 8 is about writing that novel, getting her started, big writing chunks, nothing but writing. And I figured, right, I’m not writing a novel, time to move on.

And it was good for a while, I ended up developing up half a dozen projects that are all more complete than any writing thing I’ve done before, but they’re still largely unfinished – a few I’ve mentioned to writer friends who’ve been keen to take on the burden of writing the script (and I’ve been equally keen to work with them and walk away) combined with business in drawing comics means the scripting has stopped (well, never properly started).

The dredd script I’d been working on I had so many notes that, honestly, I wasn’t sure how to synthesis them all into a single solid script and then I lost the way of myself and started doubting everything I’ve ever thought about everything. (If I’m wrong about this… can I be right about anything).

I think I need to be better keeping my enthusiasm up when I’m on my third round of notes, or, at least, be able to move on to the next thing.

The Friday Fixup has been a fun venue for writing, though like writing articles about topics I know well, it never feels like writing so much as me just spewing my thoughts out.

Just finished pencilling a six page script that was written Marvel style and it’s made me think maybe.. just maybe… I should just write some of these stories marvel style and then draw them up and dialogue them afterwards. Just purely for my own amusement.

Anyway, I’m aware this year was the year I would tackle writing and we’re more than half way through and I have one script with an artist, but nothing else written, and I just wanted to stop and take stock a little. Got to pour myself into more drawing work (WWII will be drawing this strip for several months) and hope I can find the time and energy and balls to just write and draw one thing.

Friday Fixup: PXD

Ok, art on this friday fixup is by a chap whose name is PXD (or Pete).

My general (unasked for) advice on names is this: use your real name, because whatever funny name you come up with now – before you’ve a published history WILL become your name.

My real name is Paul Holden. For publishing purposes (and because I was working with a guy called Paul Holmes who couldn’t quite grasp there were two Paul’s in the store I worked in) I started using my middle initial “J” (for Jason) for publishing, this was fine, real world, home: Paul. Online, publishing: PJ (actually my first published work is under Paul J Holden, PJ Holden scans better)

But then those world’s meet and suddenly every day you’re going “Yeah, PJ is fine. Or Paul, or Jason, or Peej. Honestly, I don’t mind”.

Frank Quitely’s name started as a joke, but of course, that’s how Vincent is no known.

These choices you make when you’re first starting out end up sticking with you for a long, long time.

(I say this because I had to check around to see what Pete’s surname was, but he seems to go by PXD too, so sorry Pete – hope I’ve credited you correctly!)

Ok, on to the art!

Pete’s page to the left, my edit to the right.

I’m not gonna talk about the lettering, but I will link to these, please go read ’em!

Ok, on to notes.

Panel 1:

Let’s stop being so shy, good big close up of our car, frames the house nicely and makes the entire thing a little more ominous. You’re always trying to fool the eye into thinking a 2d flat rectangle is a window into a 3d world, so anything that can add depth really helps that – close things look big BUT the reverse is also true : big things look close – so make something big and something small and it really gives us depth. And really push it – push it so far it breaks, then pull it back so it’s not broken but still a big contrast.

Panel 2: How wide is that door? That’s a wide door! I moved the door in a bit, added a little shadow behind the back of the door (helps frame it up a bit more) and added a little bit of texture to the unadorned wall.

Panel 3

I tried and tried to make this panel work as a straight on but it always felt odd, and the reason is she’s talking to the dude at the door, she’s facing the dude at the door, and suddenly we’re staring straight at her, from his pov – but it didn’t feel right at all, felt like we should still be observing this as a third person – so just came in nice and close to her face and repencilled her. I appreciate this is an older lady, but I think you’ve got a lot of lines on her face which are really unnecessary (I’m often guilty of this) Here’s your drawing of her face cleaned up, still older but prettier, I think. I also shrank her eyes – now you can argue this is a taste thing, but I think on your characters I’m seeing lots of eyes that are just a smidgen too large. For years and years I struggled with drawing eyes – how can you draw everything you want in an eye in the tiny space of where the eye is? IMPOSSIBLE. Couldn’t figure out how artists like Adam Hughes could draw these incredibly beautiful eyes (still can’t, if I’m honest) while I kept drawing eyes that insisted every eyelash, every wrinkle, every light red vein in an eyeball is seen. Draw less, I think is the answer. Make the lines you do draw do more.

 

pxd-face.PNG

Panel 4:

Mild perspective inside rooms are my kryptonite, I really struggle with them. (So did Mignola til that clever bastard figured out you don’t need to do it).

So what I did was a constructed a very simple version of the room in sketchup – took literally 2 minutes, dropped some figures rotated the camera until I got it more or less as it should be and then edited it based on that. I think the real problem is when you’re doing this kind of indoor perspective shot is you want to make it easy so the vanishing points end up very close together, and overlap (where the object in front hides part of the object behind) is a real pain (cus you’ve still got to figure out where the stuff is and then you don’t even draw it – it’s a blorping nightmare) so let us resolve this together – let us from now on map a very simple room (this sketchup room? two walls, a floor, no ceiling and a a simple bed that I duplicated) in sketchup and use that as the basis (you can print out a sketchup model and use that to trace over, you can export-import the 3d into clip studio to digitally trace over or you could just build the model and play with it so you get a sense of what a box room perspective looks like and then just draw it)

Pete linked me a second page, which I’ll not have time to add notes to except this: draw backgrounds! By forcing a black panel border you’ve taken away the ability to leave a panel borderless (and borderless panels also mean you can get away without background!) so you’re sort of going to have to give every panel a background (oops!) Not to worry, 90% of backgrounds are really shorthand reminders to the reader of where the location is – set in a library? then a wall of books will do. Set in a garden? a nice bit of frilly linework that looks enough like a hedge to pass will do. Cheat. I’m saying cheat. But don’t skip it.

 

Anyway, apologies PXD I feel like I’ve been unduly harsh,  of course, all of this is subjective and the advice skews heavily to my taste in things, so you are free of course, to tell me to stick it up my blorp.

 

Friday Fixup: Vince Underwood

Friday Fixup is where I take a page of some willing volunteer’s work and see if I can add some extra oomph to the story telling.

First page this week is by Vince Underwood

As ever, his version on the left, my edits to the right, annotations follow…

Let’s begin!

Panel 1:space! The final frontier. The edits: more drama! Just because we’re in space doesn’t mean we can’t have dramatic lighting around a figure (check out anything at all inked by Kevin Nowlan, the master at two source lighting). This little pure white figure against a pure white background felt a little dull, so some nice shadows inside him. Now, in panel 3 we meet some sort of villain, but where’s he come from? He just sort of appears – so I added a little flying figure of him in Panel 1 (it’s not much but it stops that can from just sort of showing up – it’s a reverse checkov’s gun problem we have – if the dude shows up as a massive threat on panel three, we’d better see him earlier than that!)

Panel 2: Couldn’t tell if we were looking at a sun or a planet, so I added some shadow shapes to help sell the planet, adding some central shadows around the flying good guy (Which really focuses you on his mouth and that scream) and added some more pew! pew! pew! (the original has two laser beams, but they’re white and on top of a white planet so it’s all a bit lost, now the planet is in shadow, added some jagged effect lines so it’s not just pure straight laser fire – visual interest! and lots more pew! pew! pew!)

(I make s/fx noises when I draw. I’ve learned to accept that about myself. Pew!)

Panel 3 – OOF! Here we want that impact point to be seen more, by adding shadow around the body of the hero that sort of guides the reader towards the chin/knee interface and adding a little white halo around the back of the villains leg, and more laser beam (pew! pew!) the panel has crunch and movement and focus.

Panel 4-6 Ok, I get what you’re doing here, a classic build up and then explosive punch! but I don’t think it’s working. Firstly the splatters of blood are too blobby and distracting, they’re not helping do anything but obstruct – this is a complex sequence so you want to simplify as much as possible. Plus, I think you’ve got Panel 4: PUNCH! Panel 5: Angry Panel 6: Angry and I think you really want Panel 4: punch! panel 5: PUNCH HARDER! panel 6: PUNCH EVEN HARDER, Panel 7: PUNCH THE HARDEST THERE IS. It’s sort of the rule of threes (I’ve gone for panels 5-6 as closer up views on the villains fist punching with blood, in case the drawing isn’t clear). Build and build and build and defuse. You have build, defuse, defuse, build, defuse.

Panel 7 (centre big punch). Ok, the centre visual effect here is cool but pointless, hard truth – it’s making me, the reader, look at the central effect and think “WHy am I staring at this dudes arm” – I’m completely missing the punch in the face that’s going on – I’m a dog that can only see on shiny thing at a time, and that shiny thing is SO shiny. So I moved the shiney to where the punch is. I did mine crudely you could do it with cooler v/fx, but the point is: the point of impact is the point. Not the dudes arm.

Panel 8-9-10 Again removed the blood splatter, so much clearer (I didn’t do it, but I’d be inclined to flip the horizontal on panel 8, as he’s arming his right hand and punching with his left, which looks a bit silly, but would work if it’s his right hand). Panel 10 I made it another punch, one with more gusto (I admit, my drawing of it is hard to make out) the point is: this is our heroes redemption moment, he gets his punch in, he’s going to win…

Panel 11: BUT WAIT! NO! Bad guy grabs him. I think you need a beat of the villain grabbing him before they start entering what I assume is limbo – I’m guessing the villain is vanishing them both away? I added a background to panel 11 (it’s the planet behind them, maybe I’d add some of the space ships too)

Panel 12-13-14-15 largely unchanged (I did add some white little lightning bolts to tie it to the visual effect on panel 7)

And finally, the background – let’s call it panel 16 I put some space ships in, because, frankly, they just seem to vanish around panel 3 where’d they go? Hopefully a reader won’t notice this stuff they’ll be so engrossed in the story, but there will be something nagging them in the back of their head, some sort of flaw they can’t quite see, and it’ll never occur to them that the spaceships just left, without a by-your-leave.

Anyway, hope that’s interesting/informative/something. YMMV on all of this stuff.

Friday Fixup: RL Rudge

Rich sent me this page (I hope you don’t mind me calling you Rich!) a fine cyberpunk type one pager.

As ever, Rich’s page first, followed by my edits followed by notes on why I did what I did…

Hey ho! Let’s go!

Panel 1: I think if you’re going to rely on perspective you need to lean hard in to it, get out the ruler, draw the guidelines. Then start measuring making sure you’ve got straight lines where you need them. I cheat (and goodness if you can cheat ALWAYS cheat) by using Clip Studio Paint’s perspective guidelines. I usually would use them to refine a pencil sketch, then I’d free hand the lines in. You’ve also got to be aware of scale – if the building is large what kind of tiny details can you see? What gives it a sense of scale? Usually it’s the number and size of windows – we all have a general notion of how big a window is so if the window looks small then boom it’s further away.

The van is suffering a bit from a flat tyre here too (I’m guessing that’s more accident than design) and we have one character walking out of it. So, I pushed us closer to the woman walking out of the van, van and her now dark heavy foreground, gives us more a sense of who’s important in this scene – on the original the building was important, in the redraw the woman looking at the building is important. Of course, check your script (which I don’t have) it may well be this shouldn’t be that type of scene – this panel is now the exorcist movie poster.

Panel two, pulled out from the van, stayed with her, dropped the panel border up top. Felt all a little close. Also It takes seconds to google “door of white transit van” give that a go! Google everything real world, you may not use it but it can suggest new shapes so everything stops looking like a persons memory of a thing.

Panel three – in the original it’s a little confusing to me, suddenly the girl we’re looking at is in the middle and beside the other guys? I think – but can’t swear, this is supposed to be a chat between them were we erase the boundaries of time and space which is cool and a comic book trope, I think though, if you’re GOING to do that then bite the bullet and do it …

heads

Floating heads are fine!

Though if you are going to do that then the very next panel BETTER HAVE A BACKGROUND! failure to do so will make the reader think they’ve entered some sort of limbo dimension where backgrounds don’t exist.

Now, what I did on this panel is I just pulled us in closer to the action (I cheated by reusing the art on panel two – which is fine for what I’m doing here, but try and avoid reproducing art in this way as it gets a bit dull and samey – it’s fine to do use a copy as a pencil if the inks then add some subtle changes. There’s room for dialogue and it’s clear where everyone is in relation to each other (I’m big on the geography of a scene, reader should never be confused about where they are UNLESS YOU WANT THEM TO BE…).

Panel Four

Hey, I’ve done backgrounds everywhere, so we can drop them out for this panel, that’s cool. It’s nice and clean and keeps our focus on our tin-chinned chum.

And that’s it. YMMV, I hope this is interesting!