Author Topic: For programmers  (Read 1240 times)

Offline Daniel

  • Feldwebel
  • ***
  • Posts: 2400
  • Thanked: 512 times
For programmers
« on: July 31, 2014, 12:02:27 PM »
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.

Code: [Select]
canvas = document.createElement('canvas'); // put a canvas onto the page
 

Offline Aquila

  • Death to Democracy
  • Wachtmeister
  • ***
  • Posts: 729
  • Thanked: 243 times
  • Religion: Roman Catholic
Re: For programmers
« Reply #1 on: August 17, 2014, 09:36:03 PM »
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.
 

Offline Daniel

  • Feldwebel
  • ***
  • Posts: 2400
  • Thanked: 512 times
Re: For programmers
« Reply #2 on: August 18, 2014, 12:07:56 AM »
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...
Code: [Select]
canvas = document.createElement('canvas'); // put a canvas onto the page
context = canvas.getContext("2d"); // get the context
 

Offline The Curt Jester

  • Water-drinker at the Coffee Social
  • St. Joseph's Workbench
  • Wachtmeister
  • ***
  • Posts: 933
  • Thanked: 304 times
  • Religion: Neo-Pelagian Angry Traditionalist with Narcissistic Tendencies
Re: For programmers
« Reply #3 on: August 18, 2014, 12:58:09 AM »
Added a line...

Code: [Select]
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!"
 

Offline Daniel

  • Feldwebel
  • ***
  • Posts: 2400
  • Thanked: 512 times
Re: For programmers
« Reply #4 on: August 18, 2014, 08:11:46 AM »
SYNTAX ERROR!!!

edit - actually, it's not a syntax error (but it doesn't exit the program either, haha).
Code: [Select]
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
« Last Edit: August 18, 2014, 08:29:12 AM by Daniel »
 

Offline The Curt Jester

  • Water-drinker at the Coffee Social
  • St. Joseph's Workbench
  • Wachtmeister
  • ***
  • Posts: 933
  • Thanked: 304 times
  • Religion: Neo-Pelagian Angry Traditionalist with Narcissistic Tendencies
Re: For programmers
« Reply #5 on: August 18, 2014, 06:55:29 PM »
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!"
 

Offline Daniel

  • Feldwebel
  • ***
  • Posts: 2400
  • Thanked: 512 times
Re: For programmers
« Reply #6 on: August 18, 2014, 07:49:34 PM »
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:
Code: [Select]
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...
« Last Edit: August 18, 2014, 07:51:57 PM by Daniel »