Chapter 5, Listing 1

Listing 1: Fruit Machine

Card-Script

on openCard
	global NEW
	put TRUE into NEW
	put 0 into cd fld "Summe"
	hide cd fld "Phrasen"
end openCard

Script of cd button "Start"

on mouseUp
	global baseIcon
	global NEW
	global j, k, l
	global Barren, Bar, Glocke, Pflaume, Orange, Kirsche
	initGewinne
	put 13405 into baseIcon
	if the hilite of me is TRUE then
		set the hilite of me to FALSE
		exit mouseUp
	else
		-- Überprüfen, ob überhaupt genug Geld zum Spielen da ist
		if item 1 of cd fld "Summe" <= 1 then
			speak "Please insert a coin first!" with female¬
			voice
			answer "Please insert a coin first"¬
			with "Thank You!"
			exit mouseUp
		end if
		set the hilite of me to TRUE
		if NEW = TRUE then
			put random(600) MOD 6 + 1 into j
			put random(600) MOD 6 + 1 into k
			put random(600) MOD 6 + 1 into l
			put FALSE into NEW
		end if
		repeat with i = 1 to random(20) + 10
			add 1 to j
			add 1 to k
			add 1 to l
			set the icon of cd button 1 to baseIcon + (j MOD 6)
			set the icon of cd button 2 to baseIcon + (k MOD 6)
			set the icon of cd button 3 to baseIcon + (l MOD 6)
		end repeat
		repeat with i = 1 to random(10) + 5
			add 1 to k
			add 1 to l
			set the icon of cd button 2 to baseIcon + (k MOD 6)
			set the icon of cd button 3 to baseIcon + (l MOD 6)
		end repeat
		repeat with i = 1 to random(10) + 5
			add 1 to l
			set the icon of cd button 3 to baseIcon + (l MOD 6)
		end repeat
		calcPayOff j MOD 6, k MOD 6, l MOD 6
		set the hilite of me to FALSE
	end if
end mouseUp

on InitGewinne
	global Barren, Bar, Glocke, Pflaume, Orange, Kirsche
	put 0 into Barren
	put 1 into Bar
	put 2 into Glocke
	put 3 into Pflaume
	put 4 into Orange
	put 5 into Kirsche
end initGewinne

on calcPayOff j, k, l
	global payOff
	global Barren, Bar, Glocke, Pflaume, Orange, Kirsche
	if (j = Barren) AND (k = Barren) AND (l = Barren) then
		put 200 into payOff
	else if (j = Bar) AND (k = Bar) AND (l = Barren) then
		put 100 into payOff
	else if (j = Glocke) AND (k = Glocke)¬
	AND (l = Glocke) then
		put 18 into payOff
	else if (j = Glocke) AND (k = Glocke)¬
	AND (l = Barren) then
		put 18 into payOff
	else if (j = Pflaume) AND (k = Pflaume)¬
	AND (l = Pflaume) then
		put 14 into payOff
	else if (j = Pflaume) AND (k = Pflaume)¬
	AND (l = Barren) then
		put 14 into payOff
	else if (j = Orange) AND (k = Orange)¬
	AND (l = Orange) then
		put 10 into payOff	
	else if (j = Orange) AND (k = Orange)¬
	AND (l = Barren) then
		put 10 into payOff
	else if (j = Kirsche) AND (k = Kirsche) then
		put 5 into payOff
	else if (j = Kirsche) then
		put 2 into payOff
	else
		put 0 into payOff
	end if
	if payOff = 0 then
		put "Nothing" into cd fld "PayOff"
		put random(8) into choice
		put line choice of cd fld "Phrasen" into phrase
		speak phrase with female voice
	else
		put payOff into cd fld "PayOff"
		play "Trumpets"
		wait until the sound is done
		speak "You won" && payOff && "Cents."¬
		with neuter voice
	end if
	add payOff-2 to item 1 of cd fld "Summe"
end calcPayOff

Script of cd button "PayOff"

on mouseUp
	global NEW
	put FALSE into NEW
	repeat with i = item 1 of cd fld "Summe" down to 1
		subtract 1 from item 1 of cd fld "Summe"
	end repeat
	play "Bye bye Baby"
	visual effect iris open slow
	go recent card
end mouseUp

© 1997 by Jörg Kantel
Zurück zum Inhaltsverzeichnis