Chapter 2, Listing 1

Listing 1: Evolutionsspiel

Script of cd button "Start"

	on mouseUp
		if the hilite of me is TRUE then
			set the hilite of me to FALSE
			set the name of me to "Start"
			exit mouseUp
		else
			set the hilite of me to TRUE
			set the name of me to "Ende mit Mausklick"
		end if
		initialisiere
		playGame
		set the hilite of me to FALSE
		set the name of me to "Start"
	end mouseUp

	on initialisiere
		put empty into cd fld "Spielfeld"
		put "init" into cd fld "Anzahl"
		-- Die sechs Felder mit den Ziffernwerten haben
		-- die Nummern 4 - 9:
		repeat with i = 4 to 9
			put 0 into cd fld i
		end repeat
		repeat with i = 1 to 6
			repeat with j = 1 to 6
				put random(6) into neu
				put neu into item i of line j of¬
				cd fld "Spielfeld"
				add 1 to cd fld (neu + 3)
			end repeat
		end repeat
	end initialisiere

	on playGame
		put 1 into anzahl
		repeat until the mouseClick
			put random(6) into x1
			put random(6) into y1
			put item x1 of line y1 of¬
			cd fld "Spielfeld" into alt
			subtract 1 from cd fld (alt + 3)
			put "0" into item x1 of line y1 of¬
			cd fld "Spielfeld"
			put FALSE into leer
			repeat until leer
				put random(6) into x2
				put random(6) into y2
				if (item x2 of line y2 of¬
				cd fld "Spielfeld") <> "0" then
					set the textStyle of¬
					item x2 of line y2¬
					of cd fld "Spielfeld" to outline
					put item x2 of line y2 of¬
					cd fld "Spielfeld" into neu
					put neu into item x1 of line y1¬
					of cd fld "Spielfeld"
					add 1 to cd fld (neu + 3)
					set the textStyle of item x2¬
					of line y2¬
					of cd fld "Spielfeld" to bold
					put TRUE into leer
				end if
			end repeat
			put anzahl into cd fld "Anzahl"
			add 1 to anzahl
			repeat with i = 4 to 9
				if item 1 of cd fld i = 36 then¬
				exit playGame
			end repeat
		end repeat
	end playGame

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