Buchempfehlung
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
"Der" Petzold, das über 1000 Seiten starke Standardwerk zum Win32-API - besonders nützlich u. a. bei der GUI-Programmierung in FreeBASIC! [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

@TB

Uploader:AdministratorSebastian
Datum/Zeit:23.07.2014 01:21:15

#include "fbgfx.bi"
#if __FB_LANG__ = "fb"
    Using FB
#endif

'==============================================================================
type thing
    private:
        x as integer
        y as integer

        vx as integer
        vy as integer

    public:
        declare function getX() as integer
        declare function getY() as integer

        declare sub setX(as integer)
        declare sub setY(as integer)
        declare sub setVX(as integer)
        declare sub setVY(as integer)

        declare sub update()
end type

function thing.getX() as integer
    return x
end function

function thing.getY() as integer
    return y
end function

sub thing.setX(x_ as integer)
    x = x_
end sub

sub thing.setY(y_ as integer)
    y = y_
end sub

sub thing.setVX(vx_ as integer)
    vx = vx_
end sub

sub thing.setVY(vy_ as integer)
    vy = vy_
end sub

sub thing.update()
    x = x + vx
    y = y + vy

    if (x < 25) or (x > 800-25) then
        vx = vx * -1
        x = x + vx
    end if
    if (y < 25) or (y > 600-25) then
        vy = vy * -1
        y = y + vy
    end if
end sub

'==============================================================================
dim as thing things(0 to 9)
for i as integer = 0 to 9
    things(i).setX(25+i*50)
    things(i).setY(25+i*50)
    things(i).setVX((i+1) mod 3 + 1)
    things(i).setVY((i+2) mod 3 + 1)
next

'==============================================================================

screen 19, 32, 2
screenset 0, 1

print("yeah")

dim lasttime as double
lasttime = timer

while not multikey(SC_ESCAPE)
    for i as integer = 0 to 9
        things(i).update()
        circle (things(i).getX(), things(i).getY()), 25, &hFF0000, , , 1, F
        line (things(i).getX(), things(i).getY())-(things((i+1) mod 10).getX(), things((i+1) mod 10).getY()),
    next

    print 1/(timer-lasttime)
    lasttime = timer

    'screensync
    screencopy
    cls

    'screenlock
    sleep 10, 1
    'screenunlock
wend