Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 08:08

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Zufallszahlenspiel

Discussion on Zufallszahlenspiel within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Dec 2008
Posts: 128
Received Thanks: 25
Zufallszahlenspiel

Hallo, da mir fad ist versuche ich aus spaß ein Zufallszahlenspiel zu basteln!
Code:
Code:
#include <GUIConstants.au3>
#include <buttonconstants.au3>
#Include <GuiListView.au3>
#include <GuiConstantsEx.au3>


Global $Form1
Global $Form2
Global $Form3
Global $Form4
Global $deinezahl
Global $Pczahl
Global $Button3
Global $Button9
Global $Button10
Global $Button11
Global $Button12
Global $Button13
Global $List1
Global $j
Global $Label8
Global $pic1
Global $Label9
Global $Input3
Global $Input4
Global $Pczahl
Global $sp1name
Global $sp1punkt
Global $sp2name
Global $sp2punkt
Global $sp3name
Global $sp3punkt
Global $sp4name
Global $sp4punkt
Global $sp5name
Global $sp5punkt

$Punkte=0
$maxzahl=0
$a=0
$min=0
$j=0

$sp1name=Iniread("Daten","Speicherstand1","Name","0")
$sp1punkt=Iniread("Daten","Speicherstand1","Punkte","0")
$sp2name=Iniread("Daten","Speicherstand2","Name","0")
$sp2punkt=Iniread("Daten","Speicherstand2","Punkte","0")
$sp3name=Iniread("Daten","Speicherstand3","Name","0")
$sp3punkt=Iniread("Daten","Speicherstand3","Punkte","0")
$sp4name=Iniread("Daten","Speicherstand4","Name","0")
$sp4punkt=Iniread("Daten","Speicherstand4","Punkte","0")
$sp5name=Iniread("Daten","Speicherstand5","Name","0")
$sp5punkt=Iniread("Daten","Speicherstand5","Punkte","0")

Hotkeyset("{Enter}","kgr")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Hauptmenü", 247, 311, 193, 125)
GUISetBkColor(0x808080)
$Button1 = GUICtrlCreateButton("(Not allowed)", 59, 13, 33, 33, $BS_BITMAP)
GUICtrlSetImage(-1, "delete.bmp", 0)
GUICtrlSetCursor (-1, 0)
$Button2 = GUICtrlCreateButton("(Not allowed)", 14, 13, 34, 34, $BS_BITMAP)
GUICtrlSetImage(-1, "save.bmp", 0)
GUICtrlSetCursor (-1, 0)
$Button3 = GUICtrlCreateButton("freier Modus", 16, 64, 209, 41, 0)
GUICtrlSetCursor (-1, 0)
$Button4 = GUICtrlCreateButton("Punkte Jagt", 16, 112, 209, 41, 0)
GUICtrlSetCursor (-1, 0)
$Button5 = GUICtrlCreateButton("Missionen", 16, 160, 209, 41, 0)
GUICtrlSetCursor (-1, 0)
$Button6 = GUICtrlCreateButton("Freispielbares", 16, 208, 209, 41, 0)
GUICtrlSetCursor (-1, 0)
$Button7 = GUICtrlCreateButton("Cheats", 16, 256, 209, 41, 0)
GUICtrlSetCursor (-1, 0)
$Label1 = GUICtrlCreateLabel("Hallo: Gast", 104, 19, 124, 24)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
	SpeichernLaden()
CAse $Button10
	laden()
Case $Button3
	Spielauswahl()
Case $Button11
	If Guictrlread($Input3) > $maxzahl Then
		MsgBox(4096,"zu groß!","Bitte wähle eine kleinere Zahl")
	Else
	Spielstartform()
EndIf
Case $Button13
	$j=1
	zeitstart()
EndSwitch
WEnd



Func SpeichernLaden ()

$Form2 = GUICreate("Speichern/ Laden", 338, 558, 303, 219)
$List1 = GUICtrlCreateListView("Speicherstand|Name|Punkte", 16, 288, 297, 149)
GUICtrlCreateListViewItem("1" & "|" & $sp1name & "|" & $sp1punkt,$List1)
GUICtrlCreateListViewItem("2" & "|" & $sp2name & "|" & $sp2punkt,$List1)
GUICtrlCreateListViewItem("3" & "|" & $sp3name & "|" & $sp3punkt,$List1)
GUICtrlCreateListViewItem("4" & "|" & $sp4name & "|" & $sp4punkt,$List1)
GUICtrlCreateListViewItem("5" & "|" & $sp5name & "|" & $sp5punkt,$List1)
$Button10 = GUICtrlCreateButton("Daten importieren", 17, 448, 297, 41, 0)
$Group1 = GUICtrlCreateGroup("Laden", 6, 256, 321, 249)
GUICtrlSetFont(-1, 12, 800, 0, "MS Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Speichern", 6, 6, 321, 249)
GUICtrlSetFont(-1, 12, 800, 0, "MS Serif")
$List2 = GUICtrlCreateListView("Speicherstand|Name|Punkte", 25, 65, 281, 139)
GUICtrlCreateListViewItem("1" & "|" & $sp1name & "|" & $sp1punkt,$List2)
GUICtrlCreateListViewItem("2" & "|" & $sp2name & "|" & $sp2punkt,$List2)
GUICtrlCreateListViewItem("3" & "|" & $sp3name & "|" & $sp3punkt,$List2)
GUICtrlCreateListViewItem("4" & "|" & $sp4name & "|" & $sp4punkt,$List2)
GUICtrlCreateListViewItem("5" & "|" & $sp5name & "|" & $sp5punkt,$List2)
$Input1 = GUICtrlCreateInput("Gib hier deinen Namen ein!", 24, 32, 281, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button8 = GUICtrlCreateButton("überschreiben", 51, 210, 233, 33, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button9 = GUICtrlCreateButton("back", 96, 512, 145, 33, 0)
GUISetState(@SW_SHOW)

EndFunc


Func laden()
		if _GUICtrlListView_GetItemSelected($List1, 0) = true then
		laden1()
	EndIf
		if _GUICtrlListView_GetItemSelected($List1, 1) = true then
		laden2()
	EndIf
		if _GUICtrlListView_GetItemSelected($List1, 2) = True then
		laden3()
	EndIf
		if _GUICtrlListView_GetItemSelected($List1, 3) = true then
		laden4() 
	EndIf
		if _GUICtrlListView_GetItemSelected($List1, 4) = true then
		laden5()
	EndIf

EndFunc

Func laden1 ()
	Guisetstate(@SW_HIDE ,$Form2)
	Guictrlsetdata($Label1, "Hallo " & $sp1name & " !")
	$Punkte = $sp1punkt
EndFunc

Func laden2 ()
	Guisetstate(@SW_HIDE ,$Form2)
	Guictrlsetdata($Label1, "Hallo " & $sp1name & " !")
	$Punkte = $sp2punkt
EndFunc

Func laden3 ()
	Guisetstate(@SW_HIDE ,$Form2)
	Guictrlsetdata($Label1, "Hallo " & $sp1name & " !")
	$Punkte = $sp3punkt
EndFunc

Func laden4 ()
	Guisetstate(@SW_HIDE ,$Form2)
	Guictrlsetdata($Label1, "Hallo " & $sp1name & " !")
	$Punkte = $sp4punkt
EndFunc

Func laden5 ()
	Guisetstate(@SW_HIDE ,$Form2)
	Guictrlsetdata($Label1, "Hallo " & $sp1name & " !")
	$Punkte = $sp5punkt
EndFunc

Func Spielauswahl ()
	If $Punkte < 100 Then
		$maxzahl=10
	EndIf
		If $Punkte >99 and $Punkte <500 Then
		$maxzahl=100
	EndIf
		If $Punkte >499 and $Punkte <2000  Then
		$maxzahl=500
	EndIf
		If $Punkte > 1999 and $Punkte < 5000 Then
		$maxzahl=2000
	EndIf
		If $Punkte > 4999 and $Punkte < 20000 Then
		$maxzahl=10000
	EndIf
		If $Punkte > 19999 and $Punkte < 100000 Then
		$maxzahl=100000
	EndIf
		If $Punkte > 99999 and $Punkte < 500000 Then
		$maxzahl=5000000
	EndIf
		If $Punkte > 499999 Then
		$maxzahl= "Unendlich"
		EndIf
$Form3 = GUICreate("Auswahl", 224, 242, 193, 125)
GUISetFont(8, 400, 0, "Papyrus")
$Label2 = GUICtrlCreateLabel("Zahl finden zwischen:", 24, 16, 170, 27)
GUICtrlSetFont(-1, 14, 800, 0, "Script MT Bold")
$Input2 = GUICtrlCreateInput("1", 32, 56, 161, 21)
$Input3 = GUICtrlCreateInput("", 32, 120, 161, 26)
$Label3 = GUICtrlCreateLabel("max. " & $maxzahl, 59, 152, 115, 29)
GUICtrlSetFont(-1, 12, 400, 0, "Papyrus")
$Label4 = GUICtrlCreateLabel("und", 95, 87, 33, 27)
GUICtrlSetFont(-1, 14, 800, 0, "Script MT Bold")
$Button11 = GUICtrlCreateButton("Start", 24, 185, 129, 41, 0)
GUICtrlSetFont(-1, 16, 400, 0, "Papyrus")
$Button12 = GUICtrlCreateButton("back", 160, 189, 49, 33, 0)
GUICtrlSetFont(-1, 10, 400, 0, "Papyrus")
GUISetState(@SW_SHOW)
EndFunc

Func spielstartform ()
	GUISetState(@SW_HIDE,$Form1)
	GUISetState(@SW_HIDE,$Form3)
		$Pczahl= Random(1,Guictrlread($Input3),1)
#Region ### START Koda GUI section ### Form=C:\Dokumente und Einstellungen\Burkhard\Desktop\Form1.kxf
$Form4 = GUICreate("Spiel", 533, 419, 201, 169)
GUISetBkColor(0x808080)
$Input4 = GUICtrlCreateInput("", 33, 216, 273, 21)
$Pic1 = GUICtrlCreatePic("keine Eingabe.bmp", 32, 16, 465, 161)
$Label5 = GUICtrlCreateLabel("Bestätige mit Enter", 338, 212, 159, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Button13 = GUICtrlCreateButton("(Not allowed)", 96, 272, 123, 123, $BS_BITMAP)
GUICtrlSetImage(-1, "C:\Dokumente und Einstellungen\Burkhard\Eigene Dateien\Eigene Bilder\images.bmp", 0)
GUICtrlSetCursor (-1, 0)
$Group3 = GUICtrlCreateGroup("Zeit ", 312, 272, 177, 129)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("min:", 343, 314, 37, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label7 = GUICtrlCreateLabel("sec:", 343, 346, 37, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label8 = GUICtrlCreateLabel("0", 398, 317, 36, 17)
$Label9 = GUICtrlCreateLabel("0", 398, 352, 36, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
EndFunc


Func kgr()
	If $j = 1 Then
	$deinezahl = GUICtrlRead($Input4)
		If $deinezahl < $Pczahl Then
			GUICtrlSetImage($pic1, "größer.bmp")
		EndIf
		If $deinezahl > $Pczahl Then
			GUICtrlSetImage($pic1, "kleiner.bmp")
		EndIf
		If $deinezahl = $Pczahl Then
			GUICtrlSetImage($pic1, "richtig.bmp")
			fertig()
		EndIf
	Else
		Msgbox(0,"starten","Biite zuerst den Start-Button drücken")
		EndIf
EndFunc

Func zeitstart()
	While 1
For $a=00 To 59 Step + 1 
	GUICtrlSetData($label9, $a)
	Sleep(1000)
	Next
	$min=$min+1
	Sleep(1000)
	GUICtrlSetData($label8, $min)

WEnd
EndFunc

Func fertig()
	Sleep(1000)
	Msgbox(0,"beendet","Spiel erfolgreich beendet in "&$min&" Minuten und "&Guictrlread($Label9)& " Sekunden!")
	GUISetState(@SW_HIDE,$Form4)
	GUISetState(@SW_SHOW,$Form1)
EndFunc
Ist im mom noch ziemlich schlicht und klein aber ich habe trotzdem schon ein Problem:

Wenn ich auf den "save" Button($Button2) drücke sollte eig nur die 2. form kommen!Es kommen aber leider hunderte fenster der 4. Form ?!
hat jemand dafür eine erklärung ?

lg lucabest
lucabest is offline  
Reply




All times are GMT +1. The time now is 08:12.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.