fb:porticula NoPaste
PingPong - Anfang
| Uploader: |  Kirodema | 
| Datum/Zeit: | 03.07.2008 22:07:29 | 
#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 movePaddel(richtung as string)
    private:
    as integer xgr, ygr, xpos, ypos
end type
constructor Paddel()
    this.xgr = 15
    this.ygr = 75
end constructor
sub Paddel.movePaddel(richtung as string)
    if richtung = "rauf" then
        cls
        ypos -= 5
        if ypos < 100 then ypos = 100
        ? "" &ypos
        drawPaddel(xpos, ypos)
        exit sub
    end if
    if richtung = "runter" then
        cls
        ypos += 5
        if (ypos + ygr) > sh then ypos = sh - ygr
        ? "" &ypos
        drawPaddel(xpos, ypos)
        exit sub
    end if
    ?"Ungueltige Richtung"
end sub
sub Paddel.drawPaddel(xpos as integer, ypos as integer)
    this.xpos = xpos
    this.ypos = ypos
    line (xpos, ypos) - (xpos + xgr, ypos + ygr),,BF
end sub
'===============================================================================
' Paddel - Ende
'===============================================================================
dim as Paddel p1, p2
dim taste as string
line (0, 100)-(sw, 100)
line (sw\2, 100) - (sw\2, sh)
circle (sw\2, 350), 100
p1.drawPaddel(50,300)
p2.drawPaddel(sw - 50, 300)
do
    taste = inkey
    if taste = oben then p1.movePaddel ("rauf")
    if taste = unten then p1.movePaddel ("runter")
    line (0, 100)-(sw, 100)
    line (sw\2, 100) - (sw\2, sh)
    circle (sw\2, 350), 100
    sleep 1
loop until taste = chr(27)
	
 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!


