This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-03-26 12:30:47

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Breakaway (a TV show) in JavaScript

Out of pure bored-ness, I created a JavaScript game inspired by the TV show called Breakaway.

I've already whipped up a piece of JS code, and I will share it to you, right in this post.

Code:

var money = 0;
var breakAway = false;
var questionNumber = 0;
function question(question,correctAnswer) {
if (questionNumber == 30) {
alert ("You won with £" + money + "!");
return;
}
if (questionNumber % 3 == 0) {
if (!breakAway) {
breakAway = confirm("Before I ask the next question, you have a choice to break away.");
}
}
var supQu = questionNumber + 1;
var answerSelected = prompt("Question " + supQu + ": " + question,"");
if (answerSelected == correctAnswer) {
money = money + 100;
alert("Correct! Money is now " + money + "!");
} else {
if (breakAway) {
document.write("You are eliminated!");
} else {
money = 0;
alert("Wrong! Money reset to 0.");
}
}
questionNumber++
}

Offline

 

#2 2012-03-27 04:24:20

ProgramCAT
Scratcher
Registered: 2011-12-13
Posts: 500+

Re: Breakaway (a TV show) in JavaScript

Nice.  smile


Programming is an art...
Goodbye, Scratch. I am leaving because of the exams coming up at our school, though I'll check the forums once or twice a week.

Offline

 

#3 2012-03-27 04:31:25

jji7skyline_test
New Scratcher
Registered: 2011-05-16
Posts: 55

Re: Breakaway (a TV show) in JavaScript

What is Breakaway?

Offline

 

#4 2012-03-27 06:13:31

nathanprocks
Scratcher
Registered: 2011-04-14
Posts: 1000+

Re: Breakaway (a TV show) in JavaScript

I think I've seen a spin-off before lol.


http://carrot.cassiedragonandfriends.org/Scratch_Signature/randomsig.php
http://trinary.site40.net/images/scratchrank.php?username=nathanprocks&display=small

Offline

 

Board footer