For programmers

Started by Daniel, July 31, 2014, 10:02:27 AM

Previous topic - Next topic

Daniel

I came across this game at a different forum.  I have no idea how many programmers we have here so it might not work out, but basically each person adds a single line of code to the program and then when the program is finished then we run it and get it to do something.  I guess we'll play in HTML5/JavaScript.  I'll start.

canvas = document.createElement('canvas'); // put a canvas onto the page

Aquila

Only works if other people know Javascript. I only know C/C++. I've also used assembly language for programming microcontrollers.
Extra SSPX Nulla Salus.
Dogmatic Sedeplenist.

Daniel

I only know high level languages (although I have wanted to learn the assembly language that's used to make Game Boy games, but I never got around to it).

My move...canvas = document.createElement('canvas'); // put a canvas onto the page
context = canvas.getContext("2d"); // get the context

The Curt Jester

Added a line...

canvas = document.createElement('canvas'); // put a canvas onto the page
context = canvas.getContext("2d"); // get the context
EXIT // Closes the program

The royal feast was done; the King
Sought some new sport to banish care,
And to his jester cried: "Sir Fool,
Kneel now, and make for us a prayer!"

The jester doffed his cap and bells,
And stood the mocking court before;
They could not see the bitter smile
Behind the painted grin he wore.

He bowed his head, and bent his knee
Upon the Monarch's silken stool;
His pleading voice arose: "O Lord,
Be merciful to me, a fool!"

Daniel

#4
SYNTAX ERROR!!!

edit - actually, it's not a syntax error (but it doesn't exit the program either, haha).canvas = document.createElement('canvas'); // put a canvas onto the page
context = canvas.getContext("2d"); // get the context
EXIT // Closes the program
= null; // and void
function draw(){ // start defining a drawing function

The Curt Jester

Quote from: Daniel on August 18, 2014, 06:11:46 AM
SYNTAX ERROR!!!

edit - actually, it's not a syntax error (but it doesn't exit the program either, haha).

Hah.  I've not done much coding, but when I did, that would work to stop the script from running.
The royal feast was done; the King
Sought some new sport to banish care,
And to his jester cried: "Sir Fool,
Kneel now, and make for us a prayer!"

The jester doffed his cap and bells,
And stood the mocking court before;
They could not see the bitter smile
Behind the painted grin he wore.

He bowed his head, and bent his knee
Upon the Monarch's silken stool;
His pleading voice arose: "O Lord,
Be merciful to me, a fool!"

Daniel

#6
Quote from: The Curt Jester on August 18, 2014, 04:55:29 PM
Quote from: Daniel on August 18, 2014, 06:11:46 AM
SYNTAX ERROR!!!

edit - actually, it's not a syntax error (but it doesn't exit the program either, haha).

Hah.  I've not done much coding, but when I did, that would work to stop the script from running.
Well JavaScript doesn't have an exit statement (at least as far as I know), and if it did then it would need to be lowercase.  So what ended up happening is the browser thought that EXIT was the name of a new variable.  But it wasn't initialized so I just set it to null (on the following line, which somehow completed the previous line... I guess that JavaScript lets you split lines of code onto multiple lines like that...)

My turn:canvas = document.createElement('canvas'); // put a canvas onto the page
context = canvas.getContext("2d"); // get the context
EXIT // Closes the program
= null; // and void
function draw(){ // start defining a drawing function
    canvas.width = 640; // oops, I should have done this outside the function...