Es geht um den Setup.
Und es geht darum, das Sachen anzeigt (oder besser nicht anzeigt) die er anzeigen soll/nicht anzeigen soll.
Ich weiß, das klingt wirr, aber so sieht es auch aus!
am besten, ihr schaut euch da mal an:
Code: Alles auswählen
; 1. Inizierung
InitSprite()
InitKeyboard()
InitSound()
OpenScreen(640,480,16,"Pong")
Global BallX.w
Global BallY.w
Global SchlaegerX.w
Global SchlaegerY.w
Global SchlaegerX2.w
Global SchlaegerY2.w
Global BewegX.w
Global BewegY.w
Global Player1.b
Global Player2.b
Global up.w
Global up2.w
Global down.w
Global down2.w
Global key.w
up = 200
down = 208
up2 = 17
down2 = 31
;OpenFile(1, "control.txt")
;up=ReadString()
;down=ReadString()
;up2=ReadString()
;down2=ReadString()
;CloseFile(1)
LoadSound(1,"pop.wav")
LoadSound(2,"laugh.wav")
Player1 = 0
Player2 = 0
max = 10
LoadFont(1,"Arial",15,#PB_Font_Bold)
LoadFont(2,"Arial",40,#PB_Font_Bold | #PB_Font_Underline)
LoadFont(3,"Arial",10,#PB_Font_Italic)
menue:
wahl1:
Delay(100)
StartDrawing(ScreenOutput())
DrawingMode(1)
ClearScreen(0,0,0)
DrawingFont(UseFont(2))
FrontColor($7B,$7B,$7B)
Locate(200,100)
DrawText("PONG")
FrontColor(255,255,255)
DrawingFont(UseFont(3))
Locate(200,160)
DrawText("by BenpiccoSoft")
Locate(200,180)
DrawText("former source by Martin Jässing")
DrawingFont(UseFont(1))
FrontColor($1B,$1E,$E4)
Locate(200,210)
DrawText("Start")
FrontColor(255,255,255)
Locate(200,230)
DrawText("Setup")
Locate(200,250)
DrawText("Exit To Windows")
StopDrawing()
FlipBuffers()
Repeat
ExamineKeyboard()
If KeyboardPushed(200)
Goto wahl3
Else
If KeyboardPushed(208)
Goto wahl2
EndIf
EndIf
Until KeyboardPushed(28)
Goto start
wahl2:
Delay(100)
StartDrawing(ScreenOutput())
DrawingMode(1)
ClearScreen(0,0,0)
DrawingFont(UseFont(2))
FrontColor($7B,$7B,$7B)
Locate(200,100)
DrawText("PONG")
FrontColor(255,255,255)
DrawingFont(UseFont(3))
Locate(200,160)
DrawText("by BenpiccoSoft")
Locate(200,180)
DrawText("former source by Martin Jässing")
DrawingFont(UseFont(1))
FrontColor(255,255,255)
Locate(200,210)
DrawText("Start")
FrontColor($1B,$1E,$E4)
Locate(200,230)
DrawText("Setup")
FrontColor(255,255,255)
Locate(200,250)
DrawText("Exit To Windows")
StopDrawing()
FlipBuffers()
Repeat
ExamineKeyboard()
If KeyboardPushed(200)
Goto wahl1
Else
If KeyboardPushed(208)
Goto wahl3
EndIf
EndIf
Until KeyboardPushed(28)
Goto setup
setup:
ClearScreen(0,0,0)
FlipBuffers()
up:
Repeat
ClearScreen(0,0,0)
StartDrawing(ScreenOutput())
DrawingMode(1)
FrontColor(255,255,255)
Locate(200,200)
DrawText("Player one, press key For up")
FlipBuffers()
StopDrawing()
Delay(100)
key = 0
ExamineKeyboard()
Repeat
If KeyboardPushed(key)
up =key
Goto down
EndIf
key = key+1
Until key=257
Until KeyboardPushed(1)
Goto up
down:
Repeat
StartDrawing(ScreenOutput())
DrawingMode(1)
ClearScreen(0,0,0)
Locate(200,200)
DrawText("Player one, press key For down")
StopDrawing()
FlipBuffers()
Delay(100)
key = 0
ExamineKeyboard()
Repeat
If KeyboardPushed(key)
down = key
Goto up2
EndIf
key = key+1
Until key=257
Until KeyboardPushed(1)
Goto down
up2:
Repeat
StartDrawing(ScreenOutput())
DrawingMode(1)
ClearScreen(0,0,0)
Locate(200,200)
DrawText("Player two, press key For up")
StopDrawing()
FlipBuffers()
Delay(100)
key = 0
ExamineKeyboard()
Repeat
If KeyboardPushed(key)
up2 = key
Goto down2
EndIf
key = key+1
Until key=257
Until KeyboardPushed(1)
Goto up2
down2:
Repeat
StartDrawing(ScreenOutput())
DrawingMode(1)
ClearScreen(0,0,0)
Locate(200,200)
DrawText("Player two, press key For down")
StopDrawing()
FlipBuffers()
Delay(100)
key = 0
ExamineKeyboard()
Repeat
If KeyboardPushed(key)
down2 = key
Goto write:
EndIf
key = key+1
Until key=257
Until KeyboardPushed(1)
Goto down2
write:
OpenFile(1,"control.txt")
UseFile(1)
WriteStringN(Str(up))
WriteStringN(Str(down))
WriteStringN(Str(up2))
WriteStringN(Str(down2))
CloseFile(1)
StartDrawing(ScreenOutput())
DrawingMode(1)
ClearScreen(0,0,0)
FlipBuffers()
StopDrawing()
Goto wahl2
wahl3:
Delay(100)
StartDrawing(ScreenOutput())
DrawingMode(1)
ClearScreen(0,0,0)
DrawingFont(UseFont(2))
FrontColor($7B,$7B,$7B)
Locate(200,100)
DrawText("PONG")
FrontColor(255,255,255)
DrawingFont(UseFont(3))
Locate(200,160)
DrawText("by BenpiccoSoft")
Locate(200,180)
DrawText("former source by Martin Jässing")
DrawingFont(UseFont(1))
Locate(200,210)
DrawText("Start")
FrontColor(255,255,255)
Locate(200,230)
DrawText("Setup")
FrontColor($1B,$1E,$E4)
Locate(200,250)
DrawText("Exit To Windows")
StopDrawing()
FlipBuffers()
Repeat
ExamineKeyboard()
If KeyboardPushed(200)
Goto wahl2
Else
If KeyboardPushed(208)
Goto wahl1
EndIf
EndIf
Until KeyboardPushed(28)
End
start:
BallX = Int(Random(400)+100)
BallY = Int(Random(300)+100)
If Int(Random(2))=1
BewegX = -1
Else
BewegX = 1
EndIf
If Int(Random(2))=1
BewegY = -1
Else
BewegY = 1
EndIf
SchlaegerX = 639 - 10
SchlaegerY = 239 - (30 / 2)
SchlaegerX2 = 1
SchlaegerY2= 239-(30-2)
Repeat
; 2. Grafik setzen
ClearScreen(0,0,0)
StartDrawing(ScreenOutput())
Circle(BallX-1,BallY-1,3,RGB(Random(255),Random(255),Random(255)))
FrontColor(255,255,255)
DrawingMode(1)
Box(10,0,620,5)
Box(10,475,620,480)
Box(SchlaegerX,SchlaegerY,10,30)
Box(SchlaegerX2,SchlaegerY2,10,30)
DrawingFont(UseFont(1))
Locate(10,10)
DrawText(Str(Player1))
Locate(620,10)
DrawText(Str(Player2))
StopDrawing()
FlipBuffers()
; 3. Abfrage der Benutzer Eingaben
ExamineKeyboard()
If KeyboardPushed(up)
SchlaegerY - 1
EndIf
If KeyboardPushed(down)
SchlaegerY + 1
EndIf
UseFont(1)
If SchlaegerY < 6
SchlaegerY = 5
ElseIf SchlaegerY > 475 - 30
SchlaegerY = 475 - 30
EndIf
ExamineKeyboard()
If KeyboardPushed(up2)
SchlaegerY2 - 1
EndIf
If KeyboardPushed(down2)
SchlaegerY2 + 1
EndIf
If SchlaegerY2 < 6
SchlaegerY2 = 5
ElseIf SchlaegerY2 > 475 - 30
SchlaegerY2 = 475 - 30
EndIf
; 4. Bewegung des Balles
BallX + BewegX
BallY + BewegY
; 5. Kollision
If BallY < 5
BewegY = 1
SoundVolume(1,50)
SoundPan(1,0)
PlaySound(1)
EndIf
If BallY > 475
BewegY = -1
SoundVolume(1,50)
SoundPan(1,0)
PlaySound(1)
EndIf
If BallX > SchlaegerX And BallX < SchlaegerX + 10 And BallY > SchlaegerY And BallY < SchlaegerY + 30
BewegX = -1
SoundVolume(1,100)
SoundPan(1,100)
PlaySound(1)
EndIf
If BallX > SchlaegerX2 And BallX < SchlaegerX2 + 10 And BallY > SchlaegerY2 And BallY < SchlaegerY2 + 30
BewegX = 1
SoundVolume(1,100)
SoundPan(1,-100)
PlaySound(1)
EndIf
If BallX > 640 Or BallX < 0
If BewegX = 1
SoundPan(2,100)
PlaySound(2)
Player1 = Player1 +1
EndIf
If BewegX = -1
SoundPan(2,-100)
PlaySound(2)
Player2 = Player2 + 1
EndIf
Goto start
EndIf
Until KeyboardPushed(1) Or Player1=max Or Player2=max
CloseScreen()
If Player1>Player2
MessageRequester("Game Over","Player 1 wins with "+Str(Player1)+" Points!",0)
End
Else
If Player1<Player2
MessageRequester("Game Over","Player 2 wins with "+Str(Player2)+" Points!",0)
End
EndIf
If Player1=Player2
MessageRequester("Game Over","Nobody wins...",0)
End
EndIf
End
EndIf Die Sounddateien sind nicht wichtig.
Wie kann man eigentlich die Zahlen aus der Dateil lesen?
Mit read word geht es scheinbar nicht...
Edit by NicTheQuick: Code eingerückt