fb:porticula NoPaste
Ping Pong - Anfang 2
| Uploader: |  Kirodema | 
| Datum/Zeit: | 05.07.2008 11:52:08 | 
#define oben chr(255,72)
#define unten chr(255,80)
screenres 800,600
dim shared as integer sw, sh
screeninfo sw, sh
'===============================================================================
' Paddel - Anfang
'===============================================================================
type Paddel
    public:
    declare constructor()
    declare sub drawPaddel(xpos as integer, ypos as Integer)
    declare sub firstDrawPaddel(xpos as integer, ypos as Integer)
    declare sub movePaddel(richtung as String, buffer As Byte Ptr)
    Declare Sub destroyImg()
    private:
    as integer xgr, ygr, xpos, ypos
    As Byte Ptr ein, aus
end type
constructor Paddel()
this.xgr = 15
this.ygr = 75
ein = ImageCreate(xgr, ygr)
aus = ImageCreate(xgr, ygr)
end constructor
sub Paddel.movePaddel(richtung as String, buffer As Byte ptr)
    Get buffer, (xpos, ypos) - (xgr, ygr), ein
    if richtung = "rauf" Then
        ypos -= 5
        if ypos < 100 then ypos = 100
        ? "" &ypos
        drawPaddel(xpos, ypos)
        Put (xpos, ypos + 5), ein
        Put (xpos, ypos), aus
        exit sub
    end if
    if richtung = "runter" Then
        ypos += 5
        if (ypos + ygr) > sh then ypos = sh - ygr
        ? "" &ypos
        drawPaddel(xpos, ypos)
        Put (xpos, ypos - 5), ein
        Put (xpos, ypos), aus
        exit sub
    end if
    ?"Ungueltige Richtung"
end sub
sub Paddel.drawPaddel(xpos as integer, ypos as Integer)
    this.xpos = xpos
    this.ypos = ypos
    line aus, (xpos, ypos) - (xpos + xgr, ypos + ygr),,BF
end Sub
sub Paddel.firstDrawPaddel(xpos as integer, ypos as Integer)
    this.xpos = xpos
    this.ypos = ypos
    line (xpos, ypos) - (xpos + xgr, ypos + ygr),,BF
end Sub
Sub Paddel.destroyImg()
    ImageDestroy ein
    ImageDestroy aus
End Sub
'===============================================================================
' Paddel - Ende
'===============================================================================
dim as Paddel p1, p2
dim taste as String
Dim bgr As Byte Ptr
bgr = ImageCreate(sw, sh)
line bgr, (0, 100)-(sw, 100)
line bgr, (sw\2, 100) - (sw\2, sh)
circle bgr, (sw\2, 350), 100
Put (0,0), bgr
p1.firstDrawPaddel(50,300)
p2.firstDrawPaddel(sw - 50, 300)
do
    taste = inkey
    If taste = oben then p1.movePaddel ("rauf", bgr)
    if taste = unten then p1.movePaddel ("runter", bgr)
    Put (0, 0), bgr
    ScreenSync
loop until taste = chr(27)
ImageDestroy bgr
p1.destroyImg()
p2.destroyImg()
?"images gelöscht"
sleep
	
 Wer ist online?
 Wer ist online? Buchempfehlung
 Buchempfehlung
 FreeBASIC-Chat
 FreeBASIC-Chat
 FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!
			FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!


