Sorry, mußte einfach sein jetzt

Code: Alles auswählen
Macro Happy
;-)
EndMacro
Happy End
Code: Alles auswählen
#breite=1280
#hoehe=1024
#max_ball=2 ; Maximale Anzahl Bälle
#schlaeger_breite=50 ; Je länger, desto leichter
InitSprite()
InitKeyboard()
InitMouse()
OpenScreen(#breite, #hoehe, 32, "Der springende Ball - AND51")
Structure structSpur
x.l
y.l
color.l
owner.l
EndStructure
NewList spur.structSpur()
Structure structBall
x.l
y.l
dirX.l
dirY.f
grav.f
owner.l
EndStructure
NewList ball.structBall()
CreateSprite(0, 30, 30)
StartDrawing(SpriteOutput(0))
Circle(15, 15, 15, #Yellow)
StopDrawing()
CreateSprite(1, #schlaeger_breite, 4)
StartDrawing(SpriteOutput(1))
FillArea(1, 1, -1, #Green)
StopDrawing()
start=Date()
Repeat
ClearScreen(0) ; 3.94 und früher: 0,0,0
ExamineKeyboard()
ExamineMouse()
DisplaySprite(1, MouseX(), MouseY())
If CountList(ball()) < #max_ball And Date() < start+10 ; Only create ball in first 10 sec of a game
AddElement(ball())
ball()\x=Random(#breite-31)+1
ball()\y=#hoehe/(Random(18)+2)
ball()\dirX=(Random(2)+2)*(Random(1)*2-1) ; Range: -4 to 4
ball()\dirY=-(Random(20)+75)/100 ; Range: -0.75 to -0.95
ball()\grav=(Random(15)+5)/100 ; Range: 0.05 to 0.20
ball()\owner=ElapsedMilliseconds()
Delay(50)
EndIf
StartDrawing(ScreenOutput())
DrawText(#breite/2, 0, "Game Duration: "+FormatDate("%hh:%ii:%ss", Date()-start), $FFFFFF, 0) ; PB 4.00, 3.94+earlier: Use Locate() !
ResetList(spur()) ; extra kein ForEach, sondern "3.94 und früher"-freundliche Programmierung =)
While NextElement(spur())
spurX=spur()\x
spurY=spur()\y
spurOwner=spur()\owner
spur()\color-2
*spur=@spur()
While NextElement(spur())
If spur()\owner = spurOwner
LineXY(spurX, spurY, spur()\x, spur()\y, spur()\color)
Break
EndIf
Wend
ChangeCurrentElement(spur(), *spur)
If spur()\color <= 0
DeleteElement(spur())
EndIf
Wend
StopDrawing()
ResetList(ball())
While NextElement(ball())
If ball()\x <= 0 Or ball()\x >= #breite-30
ball()\dirX*-1
MessageBeep_(#MB_OK)
EndIf
If SpritePixelCollision(0, ball()\x, ball()\y, 1, MouseX(), MouseY())
ball()\y=MouseY()-30
ball()\dirY*-0.95 ; Je näher an 1, desto LEICHTER wird der Ball und springt höher
MessageBeep_(#MB_OK)
EndIf
ball()\x+ball()\dirX
ball()\y+ball()\dirY
ball()\dirY+ball()\grav
AddElement(spur())
spur()\x=ball()\x+7
spur()\y=ball()\y+7
spur()\color=255
spur()\owner=ball()\owner
DisplayTransparentSprite(0, ball()\x, ball()\y)
If ball()\y >= #hoehe-30
MessageBeep_(#MB_ICONERROR)
DeleteElement(ball())
EndIf
Wend
If CountList(ball()) = 0
Break
EndIf
FlipBuffers()
Delay(10)
Until KeyboardPushed(#PB_Key_Escape)
CloseScreen()
MessageRequester("Game Over", "You have lost all balls. Game duration: "+FormatDate("%hh:%ii:%ss", Date()-start), #MB_ICONINFORMATION)
Code: Alles auswählen
Macro Happy
;-)
EndMacro
Happy End
Code: Alles auswählen
InitSprite()
InitMouse()
InitKeyboard()
ExamineDesktops()
Global sw.l, sh.l
sw = DesktopWidth(0)
sh = DesktopHeight(0)
OpenScreen(sw,sh,32,"BloederBall_v1.0")
Global ballx.f, bally.f, ballxm.f, ballym.f, pw.l, tempx.f, tempy.f, rot.f,rotm.f , pi.f
pi = 3.141592
ballx = 640
bally = 512
ballxm = 11
pw = 2000
CreateSprite(0,sw,sh,0)
StartDrawing(SpriteOutput(0))
For x = 0 To 9000
Box(Random(sw),Random(sh),16,16,RGB(0,Random(50),0))
Next
StopDrawing()
Repeat
DisplaySprite(0,0,0)
ExamineKeyboard()
ExamineMouse()
;Kraftdivision einstellen
If MouseWheel() > 0
pw + 100
If pw = 0
pw = 1
EndIf
EndIf
If MouseWheel() < 0
pw - 100
If pw = 0
pw = -1
EndIf
EndIf
If bally < -16000
bally = -16000
ballym = 0
EndIf
If MouseButton(1)
tempx = (ballx-MouseX())/pw
tempy = (bally-MouseY())/pw
ballym - tempy
ballxm - tempx
ping = 1
Else
ping = 0
EndIf
If bally < sh-16
ballym = ballym + 0.1
EndIf
bally + ballym
If bally > sh-16
bally = sh-16
ballym = -(ballym/2)
rotm = ballxm
EndIf
If ballxm > 0
ballxm - 0.01
EndIf
If ballxm < 0
ballxm + 0.01
EndIf
ballx+ballxm
If ballx > sw-16
ballx = sw-16
ballxm = -(ballxm/2)
rotm = -ballym
EndIf
If ballx < 16
ballx = 16
ballxm = -(ballxm/2)
rotm = ballym
EndIf
If rotm > 0
rotm - 0.01
EndIf
If rotm < 0
rotm + 0.01
EndIf
StartDrawing(ScreenOutput())
olposx = MouseX()
olposy = MouseY()
If ping = 1
For x = 0 To 50
If ballx > olposx
newposx = Random(16)-4
Else
newposx = Random(64)-32
If ballx < olposx
newposx = 4-Random(16)
EndIf
EndIf
If bally > olposy
newposy = Random(16)-4
Else
newposy = Random(64)-32
If bally < olposy
newposy = 4-Random(16)
EndIf
EndIf
If x = 100
newposx = olposx-ballx
newposy = olposy-bally
EndIf
Line(olposx,olposy,newposx,newposy,RGB(100-x,50-x/2,255-x*2))
olposx = olposx + newposx
olposy = olposy + newposy
Next
EndIf
Circle(ballx,bally,16,RGB(100,0,0))
rot - rotm
For x = 1 To 8
rox.f = Sin(2*pi*((rot+(x*45))/360))*15
roy.f = Cos(2*pi*((rot+(x*45))/360))*15
Line(ballx,bally,rox,roy,RGB(255,0,0))
Next
Line(MouseX(),MouseY()-16,0,32,RGB(255,255,0))
Line(MouseX()-16,MouseY(),32,0,RGB(255,255,0))
DrawingMode(1)
FrontColor(RGB(255,255,255))
DrawText(0,0,"Power-Division: "+Str(pw))
DrawText(0,16,"Ball-X: "+Str(ballx))
DrawText(0,32,"Ball-Y: "+Str(bally))
DrawText(0,48,"Ball-Move-X: "+StrF(ballxm,3))
DrawText(0,64,"Ball-Move-Y: "+StrF(ballym,3))
StopDrawing()
FlipBuffers()
ClearScreen(RGB(10,10,0))
Until KeyboardPushed(#PB_Key_Escape)
CloseScreen()
End
Code: Alles auswählen
Macro Happy
;-)
EndMacro
Happy End