Anim Camel mit Types: Funktioniert nicht...

Übersicht BlitzBasic Beginners-Corner

Neue Antwort erstellen

ReLeNtLeSS

Betreff: Anim Camel mit Types: Funktioniert nicht...

BeitragDo, Okt 25, 2007 16:59
Antworten mit Zitat
Benutzer-Profile anzeigen
Heyho,
ich wollte grade ein Animiertes Kamel meinem Spiel hinzufügen, es scheint zu funzen, doch er zeichnet es nicht:

Code: [AUSKLAPPEN]

;ForSoRace
AppTitle "ForSoRace!"
Graphics 1280,1024,32

SetBuffer BackBuffer()

;LoadImage;Loadsound

Global auto=LoadImage("data/auto.bmp")
Global autoruck=LoadImage("data/autoruck1.bmp")
Global crash=LoadImage("data/crash.bmp")
Global baum=LoadImage("data/baum.bmp")
Global crash2=LoadImage("data/crash2.bmp")
Global bg=LoadImage("data/bg.bmp")
Global maus=LoadImage("data/maus.bmp")
Global camel=LoadAnimImage("data/camel.bmp",56,50,0,3)
Global cameltot=LoadImage("data/cameltot.bmp")

MaskImage auto,255,0,255
MaskImage autoruck,255,0,255
MaskImage crash,255,0,255
MaskImage baum,255,0,255
MaskImage crash2,255,0,255
MaskImage maus,255,0,255
MaskImage camel,0,0,0

;Benötigte festgelegte Zustaende und Vars

font$=LoadFont("Arial",40,True,False,False)
SetFont font$

Global y1=100
Global y11=400
Global y21=700

Global autox=750
Global autoy=950

Global counter=0
Global points=0
Global counter_spielzeit=0
Global punkte_timer=0

Global camelcounter=0

Global aut_timer=0

Global by1=-20
Global by2=-180
Global by3=-350
Global by4=0
Global by5=-250
Global by6=-450

Global crashcount=0

Global points_check=0

Global time4

Global menu=1
Global game=0

Global time_timer=1

Global ende=0
;Types

Type auto
 Field car_x
 Field car_y
 Field points_check
End Type

Type camel
 Field camel_x
 Field camel_y
 Field points_camel
End Type

;Hautpschleife



Repeat

If menu=1 Then
menu()
EndIf

If game=1 Then
 If time_timer=1 Then
 time1=MilliSecs()
 time_timer=0
 EndIf

landscape()
auto()
create_autos()
autos_bewegen()
create_camels()
camels_bewegen()

time2=MilliSecs()
time3=time2-time1
time4=time3/600

kollisionen()

Color(255,0,0)
Text 0,0,"Aktuelle Punktzahl: "+points
Text 0,30,"Aktuelle Spielzeit: "+time4+" Secs"
Text 0,60,"Bisherige Crashes: "+crashcount
Color(255,255,255)
EndIf

If crashcount>=3 Then
the_end()
EndIf

Flip
Cls
Until KeyHit(1)

;Functions

Function menu()

DrawImage bg,0,0
DrawImage maus,MouseX(),MouseY()

Text 200,200,"Provisorisches Menu. Zum Starten Klicken!"
If MouseDown(1)=True Then
menu=0
game=1
EndIf


End Function

;__________________

Function landscape()

Color(162,156,156)
Rect 401,0,500,1024
Color(0,255,0)
Rect 0,0,400,1024
Rect 901,0,400,1024
Color(255,255,255)

Rect 650,y1,3,100,1
Rect 650,y11,3,100,1
Rect 650,y21,3,100,1

Rect 400,0,1,1024
Rect 900,0,1,1024

DrawImage(baum,60,by1)
DrawImage(baum,230,by2)
DrawImage(baum,310,by3)

DrawImage(baum,900,by4)
DrawImage(baum,1100,by5)
DrawImage(baum,1200,by6)

by1=by1+2
by2=by2+2
by3=by3+2
by4=by4+2
by5=by5+2
by6=by6+2

y1=y1+2
y11=y11+2
y21=y21+2

If by1=1024 Then by1=-20
If by2=1024 Then by2=-180
If by3=1024 Then by3=-350
If by4=1024 Then by4=0
If by5=1024 Then by5=-250
If by6=1024 Then by6=-450

If y1=1024 Then y1=0
If y11=1024 Then y11=0
If y21=1024 Then y21=0

End Function

;________________

Function auto()

DrawImage auto,autox,autoy

If KeyDown(205)=1 Then autox=autox+4
If KeyDown(203)=1 Then autox=autox-4
If KeyDown(200)=1 Then autoy=autoy-4
If KeyDown(208)=1 Then autoy=autoy+2

If autox<402 Then autox=402
If autox>850 Then autox=850
If autoy<0 Then autoy=0
If autoy>926 Then autoy=926

End Function

;______________________

Function create_autos()

     counter=counter+1 
     If counter>=30 Then
     counter=0

   
     info.auto = New auto
     info\car_x = Rnd(402,850)
     info\car_y = -20
     DrawImage autoruck,info\car_x,info\car_y

     points=points+10

    End If

End Function

;__________________

Function create_camels()

    camelcounter=camelcounter+1
    If camelcounter>=30 Then
    camelcounter=0

    cam.camel= New camel
    cam\camel_x=-20
    cam\camel_y=Rnd(10,700)
    If MilliSecs() > tmrSparks + 100 Then
        tmrSparks=MilliSecs()
        frmSparks=(frmSparks + 1) Mod 3
       End If
       DrawImage camel,camel_x,camel_y,frmSparks

  EndIf

End Function
;------------------

Function kollisionen()


 For info.auto = Each auto
    If ImagesCollide(auto,autox,autoy,0,autoruck,info\car_x,info\car_y ,0) Then       
     DrawImage crash,450,450
      If info\points_check=0 Then
         info\points_check=1
         crashcount=crashcount+1
         points=points-10
      EndIf
    Else
      info\points_check=0
    EndIf
    Next

 For cam.camel= Each camel
    If ImagesCollide(auto,autox,autoy,0,camel,cam\camel_x,cam\camel_y,0) Then
      DrawImage cameltot,cam\camel_x,cam\camel_y
       If cam\points_camel=0 Then
          cam\points_camel=0
          points=points+20
       EndIf
    Else
       cam\points_camel=0
    EndIf

Next

End Function

;------------------------

Function autos_bewegen()

For info.auto = Each auto

info\car_y=info\car_y+8

DrawImage autoruck,info\car_x,info\car_y

If info\car_y=1050 Then Delete info.auto

Next

End Function

;-----------------------

Function camels_bewegen()

For cam.camel = Each camel

cam\camel_x=cam\camel_x+1

    If MilliSecs() > tmrSparks + 100 Then
        tmrSparks=MilliSecs()
        frmSparks=(frmSparks + 1) Mod 3
       End If
       DrawImage camel,camel_x,camel_y,frmSparks

If cam\camel_x=1300 Then Delete cam.camel

Next

End Function
;-----------------------

Function the_end()

    game=0
    DrawImage crash2,0,0
    Text 345,500,"Youve totally Crashed! Save Highscore? (y/n)?
    WaitKey()


    If KeyDown(44) Then
    highscorefile$=WriteFile("Save/Your_Highscore.txt")
    CloseFile highscorefile$
    stream$=OpenFile("Save/Your_Highscore.txt")
    WriteLine stream$,"Points: "+points+" Zeit: "+time4+" Sekunden"
    Cls
    crashcount=0
    menu=1
    EndIf
                 
    If KeyDown(49) Then
    Cls
    crashcount=0
    menu=1
    EndIf
   


End Function



;__________________________


Wenn wer bescheit weis, vielen Dank!

Tankbuster

BeitragDo, Okt 25, 2007 17:13
Antworten mit Zitat
Benutzer-Profile anzeigen
Mach das CLS mal bevor du das Kamel zeichnest Wink
Twitter
Download Jewel Snake!
Windows|Android

ReLeNtLeSS

BeitragDo, Okt 25, 2007 17:25
Antworten mit Zitat
Benutzer-Profile anzeigen
Was für ein CLS denn? Es werden ja nur die Camels nich gezeichent, und ich hab das genauso wie bei den funzenden autos aufgebaut...
 

Lador

BeitragDo, Okt 25, 2007 17:31
Antworten mit Zitat
Benutzer-Profile anzeigen
Wird denn ein Kamel gezeichnet? Vielleicht liegts ja daran, dass du bei DrawImage als Parameter "camel_x" bzw. "camel_y" benutzt, und nicht "cam\camel_x" bzw. "cam\camel_y" benutzt?

MFG Lador

ReLeNtLeSS

BeitragDo, Okt 25, 2007 18:30
Antworten mit Zitat
Benutzer-Profile anzeigen
oh stimmt ja >.<

vielen dank xD

Neue Antwort erstellen


Übersicht BlitzBasic Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group