Buchempfehlung
Visual Basic 6 Kochbuch
Visual Basic 6 Kochbuch
Viele praktische Tipps zum Programmieren mit Visual Basic 6, die sich oft auch auf FB übertragen lassen. [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

der code des spiels (game.bas)

Uploader:Mitgliedflo
Datum/Zeit:15.12.2007 15:21:30

'bei den zeichnen-subs müsst ihr es so umbauen, dass ein kasten statt der figur gezeichnet wird, die teile fürs laden der grafik auskommentieren

'Programmiert von Florian Jung (icq 305-487-969)
const xlen=19,ylen=19,gravity=200,jump=100
dim shared as byte block(1 to fix(1024/xlen)+1, 1 to fix(786/ylen)+1)

#include "physics.bi"
#include "collison.bi"

declare sub FigurZeichnen()
declare sub badguyZeichnen()
declare sub Figurweg()
declare sub badguyweg()
declare sub flachdeppzeichnen()
declare sub flachdeppweg()

'dim shared Figur as TPhysics
'dim shared badguy as TPhysics
'dim shared flachdepp as TPhysics
with flachdepp
    .maxwalkstatus=3
    .walkstatus=1
    .walkspeed=.2
    .x=410
    .y=100
    .ay=gravity
    .vx=0
    .vxvorher=-50
    .width=19
    .height=10
    .stupid=true
    .unverwundbartime=.1
    .energy=2
end with

with badguy
    .maxwalkstatus=3
    .walkstatus=1
    .walkspeed=.2
    .x=600
    .y=300
    .ay=gravity
    .vx=-75
    .width=19
    .height=23
    .stupid=true
    .unverwundbartime=.1
    .energy=2
end with

with Figur
    .maxwalkstatus=3
    .walkstatus=1
    .walkspeed=.2
    .x=600
    .y=460
    .ax=0
    .ay=0
    .vx=0
    .vy=0
    .width=19
    .height=23
    .unverwundbartime=.5
    .energy=1
end with
dim as double dT

screenres  800,600,8,2
screenset 1,0

dim shared as fb.image ptr FigurSprite(1 to 3,0 to 1,1 to 2, 0 to 1)
dim shared as fb.image ptr FigurDead (1 to 3,0 to 1)
dim shared as fb.image ptr FigurHG , badguyHG,flachdeppHG,FigDeadHG

dim as integer i
for i=1 to 3
    FigurSprite(i,0,1,0)=imagecreate (19,23)
    FigurSprite(i,0,1,1)=imagecreate (19,23)
    FigurSprite(i,1,1,0)=imagecreate (19,23)
    FigurSprite(i,1,1,1)=imagecreate (19,23)
    bload "gfx\charas\schwert\l"+trim(str(i))+"-1.bmp", FigurSprite(i,0,1,0)
    bload "gfx\charas\schwert\l"+trim(str(i))+"-2.bmp", FigurSprite(i,0,1,1)
    bload "gfx\charas\schwert\r"+trim(str(i))+"-1.bmp", FigurSprite(i,1,1,0)
    bload "gfx\charas\schwert\r"+trim(str(i))+"-2.bmp", FigurSprite(i,1,1,1)
    FigurSprite(i,0,2,0)=imagecreate (19,23)
    FigurSprite(i,0,2,1)=imagecreate (19,23)
    FigurSprite(i,1,2,0)=imagecreate (19,23)
    FigurSprite(i,1,2,1)=imagecreate (19,23)
    bload "gfx\charas\schwertschlag\l"+trim(str(i))+"-1.bmp", FigurSprite(i,0,2,0)
    bload "gfx\charas\schwertschlag\l"+trim(str(i))+"-2.bmp", FigurSprite(i,0,2,1)
    bload "gfx\charas\schwertschlag\r"+trim(str(i))+"-1.bmp", FigurSprite(i,1,2,0)
    bload "gfx\charas\schwertschlag\r"+trim(str(i))+"-2.bmp", FigurSprite(i,1,2,1)
    FigurDead(i,0)=imagecreate (22,30)
    FigurDead(i,1)=imagecreate (22,30)
    bload "gfx\charas\engel\"+trim(str(i))+"-1.bmp", FigurDead(i,0)
    bload "gfx\charas\engel\"+trim(str(i))+"-2.bmp", FigurDead(i,1)
next
FigurHG=imagecreate (19,23)
badguyHG=imagecreate (19,23)
flachdeppHG=imagecreate (19,23)
FigDeadHG=imagecreate (22,30)
scope
dim as integer bx,by,obx,oby
by=1
for by=20 to 1 step -1
    for bx=23-by to 31-20+by
        block (bx,by)=-1
    next
    ?bx,by
    'for bx=5 to 10

    '    block (bx,19)=-1
    'next
next
block (15,2)=-1
for bx=1 to fix(1024/xlen)+1
    block (bx,1)=-1:block (bx,25)=-1
next
for by=1 to fix(786/ylen)+1
    block (1,by)=-1:block (34,by)=-1
next
block (3,20)=0
cls
'sleep
for bx=1 to fix(1024/xlen)+1
    for by=1 to fix(786/ylen)+1
        line(bx*xlen-xlen,by*ylen-ylen)-step(xlen,ylen),7,B
        if block (bx,by) then line(bx*xlen-xlen,by*ylen-ylen)-step(xlen,ylen),1,BF else line(bx*xlen-xlen,by*ylen-ylen)-step(xlen,ylen),4,B
    next

next
    pcopy 1,0
end scope




'put (1,1),Figursprite(1,1),pset
dT=deltaT
with Figur
.x=200
.y=170
.xalt=200
.yalt=170
.obx=fix(figur.x/xlen)+1
.oby=fix(figur.y/ylen)+1
end with
get (Figur.x,Figur.y)-step(Figur.width-1,Figur.height-1),FigurHG
get (badguy.x,badguy.y)-step(badguy.width-1,badguy.height-1),badguyHG
get (flachdepp.x,flachdepp.y)-step(flachdepp.width-1,flachdepp.height-1),flachdeppHG


dim shared as double schlag
dim as byte keinschlag
do


    sleep 10
    'locate 3,1:?Figur.energy;"   "
    dT=deltaT

    Flachdeppweg
    BadGuyweg
    Figurweg

    if Figur.energy=0 then
        beep
        'sleep 500
        with Figur
            .xalt=.x:.yalt=.y
            get (.x,.y)-step(21,29),FigDeadHG
            'beep
            locate 1,1:?.x,.y
            Figur.ax=0:Figur.vx=0:Figur.ay=0:Figur.vy=-100:Figur.vxalt=0:Figur.vyalt=0
            do

                put (.xalt,.yalt),FigDeadHG,pset
                get (.x,.y)-step(21,29),FigDeadHG
                put (.x,.y),FigurDead(.walkstatus,1),or
                put (.x,.y),FigurDead(.walkstatus,0),and
'                if timer-.walktime>.walkspeed then
'                    .walktime=timer
'                    .walkstatus+=1
'                    if .walkstatus>.maxwalkstatus then .walkstatus=1
'                end if
'
                pcopy 1,0
                locate 1,1:?.x,.y,.walkstatus
                sleep 10
                dT=deltaT
                move Figur,dT
            loop until .y <0
            end
        end with
    end if





    FigurZeichnen
    badguyZeichnen
    flachdeppzeichnen

    if multikey(&h48) and Figur.ay=0 then Figur.ay=gravity:Figur.vy=-jump
    if multikey(&h4b) then Figur.vx=-75 else if multikey(&h4d) then Figur.vx=75 else Figur.vx=0
    if multikey(&H1D) then
        if schlag =0 and keinschlag=0 then
            schlag=timer
            keinschlag=-1
        end if
    else
        schlag =0
        keinschlag=0
    end if

    if timer-schlag>0.1  then schlag=0
    do until inkey="" : loop
    move Figur,dT
    collisionstop Figur
    if badguy.energy>0 then
        'move badguy,dT
        'collisionstop badguy
        aua Figur,badguy
    end if
    if flachdepp.energy>0 then
        'move flachdepp,dT
        'flachcollisionstop flachdepp
        aua Figur,flachdepp
    end if




    if schlag then
        schlagtest Figur,badguy
        schlagtest Figur,flachdepp
    end if

    'locate 1,1:?Figur.energy,badguy.energy,flachdepp.energy

    locate 1,1:?figur.ay;"  "
    locate 2,1:?fix(1/dT) ; "FPS"

    pcopy 1,0
    'screensync

    'vsync
loop

'sub FigurZeichnen
'    static temp as byte ,zeit as double,direction as byte,_move as integer ,omove as integer
'    if _move=0 then _move=((direction*2)-1)*5
'    'dim as integer _move
'    if Figur.vx<0 then direction=0:_move=-4 else if Figur.vx>0 then direction = 1:_move=4
'    if abs(timer-zeit)>0.2 then zeit=timer:temp=temp+1: if temp>3 then temp=1
'    if Figur.vx=0 then temp=1
'    'temp+=1    : if temp=4 then temp=1
'    put (Figur.xalt+omove,Figur.yalt-Figur.height+2),FigurHG,pset
'    omove=_move
'    ' _move=((direction*2)-1)*5
'
'    get (Figur.x+_move,Figur.y-Figur.height+2)-step(Figur.width-1,Figur.height-1),FigurHG
'
'    put (Figur.x+_move,Figur.y-Figur.height+2),FigurSprite(temp,direction,1-(schlag<>0),1),or
'    put (Figur.x+_move,Figur.y-Figur.height+2),FigurSprite(temp,direction,1-(schlag<>0),0),and
'    'line(figur.x,figur.y-24)-step(23,23),3,BF
'end sub
'sub badguyZeichnen
'    with badguy
'    'static temp as byte ,zeit as double
'    if .move=0 then .move=((.direction*2)-1)*5
'    'dim as integer _move
'    if badguy.vx<0 then .direction=0:.move=-4 else if badguy.vx>0 then .direction = 1:.move=4
'    if abs(timer-.walktime)>.walkspeed then .walktime=timer:.walkstatus=.walkstatus+1: if .walkstatus>3 then .walkstatus=1
'    if badguy.vx=0 then .walkstatus=1
'    'temp+=1    : if temp=4 then temp=1
'    put (badguy.xalt+.omove,badguy.yalt-badguy.height+2),badguyHG,pset
'    .omove=.move
'    ' _move=((direction*2)-1)*5
'
'    get (badguy.x+.move,badguy.y-badguy.height+2)-step(badguy.width-1,badguy.height-1),badguyHG
'
'    put (badguy.x+.move,badguy.y-badguy.height+2),FigurSprite(.walkstatus,.direction,1-(schlag<>0),1),or
'    put (badguy.x+.move,badguy.y-badguy.height+2),FigurSprite(.walkstatus,.direction,1-(schlag<>0),0),and
'    'line(figur.x,figur.y-24)-step(23,23),3,BF
'    end with
'end sub
'

sub FigurWeg
    with Figur
        put(.xalt+.omove,.yalt-.height+2),FigurHG,pset
    end with
end sub

sub BadGuyWeg
    with BadGuy
        if .energy>-1 then put(.xalt+.omove,.yalt-.height+2),BadGuyHG,pset: if .energy=0 then .energy=-1
    end with
end sub

sub flachdeppWeg
    with flachdepp
        if .energy>-1 then put(.xalt+.omove,.yalt-.height),flachdeppHG,pset: if .energy=0 then .energy=-1
    end with
end sub

sub flachdeppZeichnen
    with flachdepp
        if .energy>0 then
            get (.x+.move,.y-.height)-step(.width-1,.height-1),FlachDeppHG
            line (.x,.y-.height)-step(.width-1,.height-1),1,BF
        end if

    end with
end sub

sub FigurZeichnen
    with Figur
        if .nowmove=0 then .nowmove=((.direction*2)-1)*.move
        get (.x+.move,.y-.height+2)-step(.width-1,.height-1),FigurHG
        put (.x+.move,.y-.height+2),FigurSprite(.walkstatus,.direction,1-(schlag<>0),1),or
        put (.x+.move,.y-.height+2),FigurSprite(.walkstatus,.direction,1-(schlag<>0),0),and
        .omove=.nowmove
    end with
end sub
sub badguyZeichnen
    with badguy
        if .energy>0 then
            if .nowmove=0 then .nowmove=((.direction*2)-1)*.move
            get (.x+.move,.y-.height+2)-step(.width-1,.height-1),badguyHG
            put (.x+.move,.y-.height+2),FigurSprite(.walkstatus,.direction,1-(schlag<>0),1),or
            put (.x+.move,.y-.height+2),FigurSprite(.walkstatus,.direction,1-(schlag<>0),0),and
            .omove=.nowmove
        end if

    end with
end sub