Grafiken Flimmern

Übersicht BlitzBasic Beginners-Corner

Gehe zu Seite 1, 2  Weiter

Neue Antwort erstellen

Devils Child

Betreff: Grafiken Flimmern

BeitragDo, Sep 01, 2005 3:07
Antworten mit Zitat
Benutzer-Profile anzeigen
hi!

also, ich hab ein spielchen, und darauf eine anzeige, die health und so anzeigt.

ich hab auf der anzeige print, line und rect und drawimage benutzt, um die anzeige zu gestalten

andere sagen mir, dass bei denen die anzeige stark flimmert, woran kann das liegen?
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

Firstdeathmaker

BeitragDo, Sep 01, 2005 7:02
Antworten mit Zitat
Benutzer-Profile anzeigen
Benutzt du kein Doublebuffering? Also BlitzBasic: [AUSKLAPPEN]
SetBuffer BackBuffer()
und am ende BlitzBasic: [AUSKLAPPEN]
Flip


Ach solltest du dann von Print die finger lassen, weil das nur auf den Frontbuffer schreibt. Benutze stattdessen BlitzBasic: [AUSKLAPPEN]
Text
www.illusion-games.de
Space War 3 | Space Race | Galaxy on Fire | Razoon
Gewinner des BCC #57 User posted image

Alfadur

BeitragDo, Sep 01, 2005 13:00
Antworten mit Zitat
Benutzer-Profile anzeigen
liegt daran das die vsync einstellungen bei denen anders sind als bei dir ... mußt halt ne option für vsync einbauen und dann flip mit 0 oder 1 ...
A Cray is the only computer that runs an endless loop in less than four hours.

Devils Child

BeitragDo, Sep 01, 2005 13:42
Antworten mit Zitat
Benutzer-Profile anzeigen
ja, oben steht setbuffer backbuffer() und ich benutzt immer flip nachdem ich das display gezeichnet hab, da sind auch images, die flimmern auch!

was ist vsync?
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

hectic

Sieger des IS Talentwettbewerb 2006

BeitragDo, Sep 01, 2005 14:07
Antworten mit Zitat
Benutzer-Profile anzeigen
Vertikale Syncronisation (VSync) des 'Elektrodenstrahls'. Bedeutet: Die Grafikkarte lässt den Rechner solange warten bis das alte Bild vom Monitor fertig gezeichnet wurde, um dann das neue komplette Bild vom (Grafikspecher) BackBuffer zum (Grafikspeicher) FrontBuffer um zu lenken. Du zeichnest also immer im Hintergrund und wenn es fertig gezeichnet wurde, wird es auf dem Bildschirm gebracht, aber erst wenn der Monitor sein Bild abgeschlossen hat. Dadurch wird das Spiel natürlich etwas langsamer. Aber 300FPS kann sowieso noch kein Monitor/Bildschirm darstellen. Bei flachbildschirmen gibt es sicherlich kein Elektrodenstrahl, denoch haben die eine festgelegte Wiederholrate (zB 60 FPS), das VSync-Signal wird dennoch vom Bildschirm ausgesendet. Ist Flip auf 0 gestellt (VSync ausgeschaltet), dann kann es zu Verzerungen der dargestellten Objekte bei horizontaler Bewegung und bei vertikaler zur 'Streckungen/Stauchungen' kommen. Aber auch flimmern.

Bei Spielen würde ich immer Flip 1 machen. Bei Simulationen und Berechnungen, wo es auf Rechnergeschwindigkeit ankommt (zB: Sternenbewegungssimulationen, Videorendering...), würde ich Flip auf 0 stellen.

Devils Child

BeitragDo, Sep 01, 2005 14:36
Antworten mit Zitat
Benutzer-Profile anzeigen
ich hab ja nicht flip 0 sdondern flip 1 und ich hab den backbuffer an, also was mach ich falsch?
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

Alfadur

BeitragDo, Sep 01, 2005 15:37
Antworten mit Zitat
Benutzer-Profile anzeigen
mach flip 0.

ich dachte bei dir gehts, nur bei deinen freunden gehts nicht...? oder wie oder was?
A Cray is the only computer that runs an endless loop in less than four hours.

Devils Child

BeitragDo, Sep 01, 2005 15:47
Antworten mit Zitat
Benutzer-Profile anzeigen
ja, bei mir gehts und bei meinen freunden nicht, aber mit flip 0 gehts selbst bei mir nicht mehr
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

Firstdeathmaker

BeitragDo, Sep 01, 2005 15:59
Antworten mit Zitat
Benutzer-Profile anzeigen
Wie groß ist der Code? Könntest du den mir mal schicken, damit ich das hier testen kann? Vielleicht entdecke ich ja einen Fehler...
www.illusion-games.de
Space War 3 | Space Race | Galaxy on Fire | Razoon
Gewinner des BCC #57 User posted image

Waveblue

BeitragDo, Sep 01, 2005 16:20
Antworten mit Zitat
Benutzer-Profile anzeigen
läuft das Spiel mit einer andren Auflösung als du im Moment eingestellt hast?

wenn ja:
stell diese Auflösung ein! Wenn dann dein Schirm schon flimmert,
geh auf deine Grafikeinstellungen und regele da die Bildwiederholrate auf 85 hertz!
This is 10% luck
20% skill
15% concentrated power of will
5% pleasure, 50% pain
and 100% reason to remember the name
 

Ava

Gast

BeitragDo, Sep 01, 2005 17:33
Antworten mit Zitat
Ich habe nun nicht alles gelesen (nur die Einführung und kurz die anderen Post überflogen), aber: benutze keinen Print-Befehl! nimm Text! !

Print verschiebt die Grafikausgabe und führt da leicht mal zu unerwünschten Flimmereffekten. *sich an ihre Blitzbasic Anfäge zurückerinnert* Rolling Eyes

8)

Devils Child

BeitragDo, Sep 01, 2005 17:43
Antworten mit Zitat
Benutzer-Profile anzeigen
aber rect, oval, line und drawimage kann ich nicht durch irgendwas ersetzen, und das ist es was flimmert
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

Firstdeathmaker

BeitragDo, Sep 01, 2005 18:03
Antworten mit Zitat
Benutzer-Profile anzeigen
Die braucht man ja auch nicht durch etwas anderes zu ersetzen, die gehen ja ok.
www.illusion-games.de
Space War 3 | Space Race | Galaxy on Fire | Razoon
Gewinner des BCC #57 User posted image

Devils Child

BeitragFr, Sep 02, 2005 8:51
Antworten mit Zitat
Benutzer-Profile anzeigen
also, andere sagen es ruckelt, und der arm mit der waffe den ich jedes bild rendere und dann als image zeichne damit er nicht in wänden verschwindet flimmert auch. bei mir aber net Crying or Very sad
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN
 

Ava

Gast

BeitragFr, Sep 02, 2005 10:51
Antworten mit Zitat
Hast Du denn nun das Print mal ausgetauscht und es flimmert unverändert? Exclamation Question

D2006

Administrator

BeitragFr, Sep 02, 2005 11:46
Antworten mit Zitat
Benutzer-Profile anzeigen
Vorschlag:
Du zeigst ein wenig Code und wir helfen dir.

Wenn das hier so weiter rumeiert, weil du keinen Code rausrückst, ist der Thread höchstens Trash wert.

Eins ist er auf jedenfall schon wert: Beginner Bereicht. Das stinkt mir zu sehr nach Double Buffering Anfänger Problem.

~Verschoben~

MfG
D2006

Devils Child

BeitragFr, Sep 02, 2005 12:13
Antworten mit Zitat
Benutzer-Profile anzeigen
ok, das ist der mission to hell-source code, ohne die physinkengine und so, und ohne medien:

Code: [AUSKLAPPEN]
Include "GlobalConstDimType.bb"
Include "Intro.bb"
Include "HellEngine.bb"
Include "BlitzUI.bb"

LoadColourScheme("Data\UIScheme.cs")
DefaultSettings()

.Menu
FreeWorld()
Graphics 1024, 768, 32, 1
SetBuffer BackBuffer()
.MenuWithoutGraphics

Initialise()
Destroy()

Img_BackGround = LoadImage("Gfx\BackGround.jpg")
Img_Pointer =    LoadImage("Gfx\Pointer.bmp")
MaskImage Img_Pointer, 0, 0, 255

Snd_ButtonClick =    LoadSound("Sound\Ui\ButtonClick.wav")
Snd_ButtonRollOver = LoadSound("Sound\Ui\ButtonRollOver.wav")

Global MFont1 = LoadFont("Serpentine", 20, False, False, False)
Global MFont2 = LoadFont("Courier New", 20, False, False, False)
Global MFont3 = LoadFont("Courier New", 20, True, False, False)

Dim mentx$(5), helptx$(5)

mentx$(1) = "New Game"
mentx$(2) = "Free Look"
mentx$(3) = "Settings"
mentx$(4) = "Credits"
mentx$(5) = "Quit"
helptx$(1) = "Starts a new game or begins at the current chapter."
helptx$(2) = "You can see the maps, without enemies and monsters!"
helptx$(3) = "You can set Settings for the Game"
helptx$(4) = "Read a little bit about the team."
helptx$(5) = "Quits the game."

sel = 0
While Not KeyHit(1)
  DrawImage Img_BackGround, 0, 0

  ;Menu Choose
  sel1 = 0
  For i = 1 To 5
    If MouseX() > 100 And MouseY() > 300 + i * 23 And MouseX() < 260 And MouseY() < 324 + i * 23 Then
      Color 200, 200, 255
      Rect 90, 300 + i * 23, 170, 20
      Color 0, 0, 0
      Rect 90, 300 + i * 23, 170, 20, 0
      Rect 91, 301 + i * 23, 168, 18, 0
      sel1 = i
    EndIf
    If MouseDown(1) Then
      click1 = sel1
      If oldclick1 <> click1 Then CreateSound(Snd_ButtonClick)
      oldclick1 = click1
      If sel1 = 1 Then Flip: Goto Game
      If sel1 = 2 Then Goto FreeLook
      If sel1 = 3 Then Flip: Goto Settings
      If sel1 = 4 Then Flip: Goto Credits
      If sel1 = 5 Then End
    EndIf
  Next
  If sel1 <> oldsel1 Then CreateSound(Snd_ButtonRollOver)
  oldsel1 = sel1
  For i = 1 To 5
    SetFont MFont1
    Color 255, 230, 0
    Text 100, 300 + i * 23, mentx$(i)
    SetFont MFont2
    Color 200, 200, 200
    Text 300, 301 + i * 23, helptx$(i)
  Next

  DrawImage Img_Pointer, MouseX(), MouseY()
  Flip
Wend
End

.Credits
CopyRect 0, 0, GraphicsWidth(), GraphicsHeight(), 0, 0, 0, ImageBuffer(Img_BackGround)
Initialise()

;CreditsWindow
winMain = Window(app\W / 2 - 153, app\H / 2 - 140, 307, 359, "Credits", 0, True, False, False, False)
imgLogo = Image(10, 10, 284, 121, LoadImage("Gfx\Logo.jpg"))
lbl01 =   Label(70, 145, "Copyright by Xware-Entertainment")
lbl02 =   Label(70, 160, "        - Patrick Schefczyk")
lbl03 =   Label(70, 175, "        - Moritz Schneider")
lbl04 =   Label(70, 190, "          - Martin Fiser")
lbl05 =   Label(70, 205, "        - Andreas Philippi")
lbl06 =   Label(70, 230, "        in corporation with")
lbl07 =   Label(70, 245, "          Dietmar Herzberg")
lbl08 =   Label(70, 265, "     visit us at our homepage:")
lbl09 =   Label(70, 280, "     www.Xware-Entertainment.de")
btnOK =   Button(115, 303, 70, 20, "OK")

;Update UI
While Not app\Quit Or KeyDown(1)
  Cls
  DrawImage Img_BackGround, 0, 0
  UpdateGUI()
  If app\Event = EVENT_GADGET And app\GadgetEvent = btnOK Then Exit
  DrawMouse()
  ResetEvents()
  Flip
Wend
Destroy()
Goto MenuWithoutGraphics

.Settings
CopyRect 0, 0, GraphicsWidth(), GraphicsHeight(), 0, 0, 0, ImageBuffer(Img_BackGround)
Initialise()

;Main Window
winMain =        Window(app\W / 2 - 150, app\H / 2 - 140, 245, 265, "Settings", 0, True, False, False, False)
tabMain =        Tab(10, 10, 220, 180)
gppUnderLine =   GroupBox(10, 200, 220, 2, "")

;--- Butons ---
btnOK =          Button(10, 210, 70, 20, "OK")
btnAbort =       Button(85, 210, 70, 20, "Abort")
btnDefaults =    Button(160, 210, 70, 20, "Defaults")

;--- Graphics ---
tabpGraphics =   TabPage("Graphics")
;Resolution
lblResolutions = Label(13, 3, "Resolutions:")
lstResolutions = ListBox(13, 17, 100, 130, "Resolutions")
;CheckBoxes
chkCrossair =    CheckBox(130, 17, "Crossair")
chkShadows =     CheckBox(130, 34, "Shadows"): SendMessage(chkShadows, "CM_DISABLE")
;Renderer
grpRenderer =    GroupBox(130, 55, 80, 65, "Renderer")
radSoftware =    Radio(137, 67, "Software"): SendMessage(radSoftware, "RM_DISABLE")
radOpenGL =      Radio(137, 84, "OpenGL"):   SendMessage(radOpenGL, "RM_DISABLE")
radDirectX =     Radio(137, 101, "DirectX"): SendMessage(radDirectX, "RM_SETCHECKED", True): SendMessage(radDirectX, "RM_DISABLE")

;--- Movement ---
tabpMovement =   TabPage("Movement")
chkInvMouse =    CheckBox(10, 10, "Invert Mouse")
lblMouseSens =   Label(13, 32, "Mouse Sensity:")
spnMouseSens =   Slider(13, 49, 100, 10)
lblSpnMSValue =  Label(123, 49, "")

;--- Sound ---
tabpSound =      TabPage("Sound")
chkSound =       CheckBox(10, 10, "Sound")
lblSoundVolume = Label(13, 32, "Sound Volume:")
spnSoundVolume = Slider(13, 49, 100, 10)
lblSpnSVValue =  Label(123, 49, "")

;Set first tappage on tab
tab.Tab = Object.Tab(tabMain)
tab\Active = Object.TabPage(tabpGraphics)

;Insert Resolutions
Dim width(100), height(100)
file = ReadFile("Data\Resolutions.ini")
cnt = 0
While Not Eof(file)
  cnt = cnt + 1
  txt$ = ReadLine(file)
  For i = 1 To Len(txt$)
    If Mid$(txt$, i, 1) = "x" Then
      width(cnt) = Left$(txt$, i - 1)
      height(cnt) = Right$(txt$, i - 1)
      If GfxModeExists(width(cnt), height(cnt), 32) Then
        SendMessage(lstResolutions, "LM_SETTEXT", cnt - 1, txt$)
      Else
        cnt = cnt - 1
      EndIf
    EndIf
  Next
Wend
lst.ListBox = Object.ListBox(lstResolutions)
lst\Count = cnt
CloseFile file

;Set Settings to UI
SendMessage(chkInvMouse,    "CM_SETCHECKED", Cfg_InvMouse)
SendMessage(chkCrossair,    "CM_SETCHECKED", Cfg_Crossair)
SendMessage(chkSound,       "CM_SETCHECKED", Cfg_Sound)
SendMessage(spnMouseSens,   "SM_SETVALUE",   Cfg_MouseSensity * 20 - 10)
SendMessage(spnSoundVolume, "SM_SETVALUE",   Cfg_SoundVolume * 100)
lst.ListBox = Object.ListBox(lstResolutions)
For i = 0 To lst\Count
  If Cfg_Width = width(i) And Cfg_Height = height(i) Then SendMessage(lstResolutions, "LM_SETINDEX", i)
Next

;Update UI
While Not app\Quit Or KeyDown(1)
  Cls
  DrawImage Img_BackGround, 0, 0
  UpdateGUI()
  Select app\Event
    Case EVENT_GADGET
      Select app\GadgetEvent
        Case btnOK:    Goto ssfsm ;Save Settings From Settings Menu
        Case btnAbort: Goto MenuWithoutGraphics
        Case btnDefaults
          DefaultSettings()
          Goto MenuWithoutGraphics
      End Select
  End Select
  SendMessage(lblSpnMSValue, "LM_SETTEXT", Float(SendMessage(spnMouseSens,   "SM_GETVALUE")) / 20 + .5)
  SendMessage(lblSpnSVValue, "LM_SETTEXT", Float(SendMessage(spnSoundVolume, "SM_GETVALUE")) / 100)
  DrawMouse()
  ResetEvents()
  Flip
Wend
Goto MenuWithoutGraphics
.ssfsm
Cfg_Width = width(SendMessage(lstResolutions, "LM_GETINDEX"))
Cfg_Height = height(SendMessage(lstResolutions, "LM_GETINDEX"))
Cfg_InvMouse = SendMessage(chkInvMouse, "CM_GETCHECKED")
Cfg_Crossair = SendMessage(chkCrossair, "CM_GETCHECKED")
Cfg_MouseSensity = Float(SendMessage(spnMouseSens,  "SM_GETVALUE")) / 20 + .5
Cfg_SoundVolume = Float(SendMessage(spnSoundVolume, "SM_GETVALUE")) / 100
Cfg_Sound = SendMessage(chkSound, "CM_GETCHECKED")
If Cfg_Sound = False Then Cfg_SoundVolume = 0
Goto MenuWithoutGraphics

.Game
CopyRect 0, 0, GraphicsWidth(), GraphicsHeight(), 0, 0, 0, ImageBuffer(Img_BackGround)
Initialise()

winMain =    Window(300, 200, 330, 210, "New Game", 0, True, False, False, False)
btnOK =      Button(10, 160, 70, 20, "OK")
btnAbort =   Button(90, 160, 70, 20, "Abort")
lstChoose =  ListBox(10, 10, 310, 150)

SendMessage(lstChoose, "LM_SETTEXT", 0, "Tutorial")
SendMessage(lstChoose, "LM_SETTEXT", 1, "Chapter1 - Another world     (n/a)")
SendMessage(lstChoose, "LM_SETTEXT", 2, "Chapter2 - On a mission      (n/a)")
SendMessage(lstChoose, "LM_SETTEXT", 3, "Chapter3 - Collecting energy (n/a)")
SendMessage(lstChoose, "LM_SETTEXT", 4, "Chapter4 - The Big Eye")

lst.ListBox = Object.ListBox(lstChoose)
lst\Count = 5
lst\ActiveIndex = 2

;Update UI
While Not app\Quit Or KeyDown(1)
  Cls
  DrawImage Img_BackGround, 0, 0
  UpdateGUI()
  Select app\Event
    Case EVENT_WINDOW
      Select app\WindowEvent
      End Select
    Case EVENT_MENU
      Select app\MenuEvent
      End Select
    Case EVENT_GADGET
      Select app\GadgetEvent
        Case btnOK
          Select lst\ActiveIndex
            Case 1: Goto Tutorial
             Case 2: Goto Chapter1
;;             Case 3: Goto Chapter2
             Case 4: Goto Chapter3
             Case 5: Goto Chapter4
          End Select
        Case btnAbort
          Goto MenuWithoutGraphics
      End Select
  End Select
  If lst\ActiveIndex = 0 Then
    SendMessage(btnOK, "BM_DISABLE")
  Else
    SendMessage(btnOK, "BM_ENABLE")
  EndIf
  DrawMouse()
  ResetEvents()
  Flip
Wend
Destroy()
Goto MenuWithoutGraphics

.FreeLook
Graphics3D Cfg_Width, Cfg_Height, 32, 1
SetFont LoadFont("Courier New", GraphicsHeight() / 40, False, False, False)

;Cam
Cam = CreateCamera()
CameraRange Cam, 1, 10000
PositionEntity Cam, 8.4, 5.8, -8.6
EntityRadius Cam, .5, 20
EntityType Cam, BODY

;WPiv
WPiv = CreatePivot()

;Light
Light = CreateLight()
RotateEntity Light, 45, 45, 0

;Map
Tex_Water = LoadTexture("Textures\Water.bmp")
Tex_Grenade = LoadTexture("Textures\Grenade.bmp")

Map = LoadMap_Office()
SkyBox = LoadSkyBox()

While Not KeyHit(1)
  ;Walking
  Sp# = .05
  If KeyDown(42) Then Sp# = Sp# * 2
  If KeyDown(17) Then ZSpeed# = ZSpeed# + Sp#
  If KeyDown(31) Then ZSpeed# = ZSpeed# - Sp#
  If KeyDown(30) Then XSpeed# = XSpeed# - Sp#
  If KeyDown(32) Then XSpeed# = XSpeed# + Sp#
  XSpeed# = XSpeed# * .9
  ZSpeed# = ZSpeed# * .9
  MoveEntity Cam, XSpeed, 0, ZSpeed#

  ;FPS
  time# = MilliSecs()
  If time# - oldtime# <> 0 Then fps =  Int(1 / (time# - oldtime#) * 1000)
  If fps = 0 Then fps = 1
  oldtime# = MilliSecs()

  Locate  1, 100
  Print "Camera Position:"
  Print "----------------"
  Print "X: " + EntityX(Cam)
  Print "Y: " + EntityY(Cam)
  Print "Z: " + EntityZ(Cam)

  UpdateCatapults(Cam)

  MouseLook(Cam)
  PositionEntity SkyBox, EntityX(Cam), EntityY(Cam), EntityZ(Cam)
  RenderWorld
  Flip
Wend
FreeWorld()
EndGraphics
Goto Menu

.Tutorial
Init()
PrepareGame(0)
Map = LoadMap_TutorialMap()
ChapterBegin(0)

;Equipment Pack
Equip = LoadMesh("Models\Equipment\Equipment.b3d")
ScaleEntity Equip, .3, .3, .3
PositionEntity Equip, 73, 2.8, 18
EntityParent Equip, WPiv
tr_eq = False

CreateSound(LoadSound("Sound\Cheaf\Chapter0.wav"))

While Not KeyHit(1)
  hotug = Int(100 / fps)
  If hotug > 7 Then hotug = 7
  OldSelWeapon = SelWeapon
  For HowOftenToUpdateGame = 1 To hotug
    Gosub UpdateGame
    timer = (timer + 1) Mod 140
  Next

  ;Equipment Pack
  If tr_eq = False Then
    If EntityDistance(Cam, Equip) < 3.5 Then
      CreateSound(Snd_GotItem)
      tr_eq = True
      FreeEntity Equip
      WeaponEnabled = True
    EndIf
  EndIf

  ;FPS
  time# = MilliSecs()
  If time# - oldtime# <> 0 Then fps =  Int(1 / (time# - oldtime#) * 1000)
  If fps = 0 Then fps = 1
  oldtime# = MilliSecs()

  ;Render-System
  TranslateEntity Cam, 0, 1.7, 0
  HideEntity Wpiv
  HideEntity BloodBall
  RenderWorld
  CopyRect 0, 0, GraphicsWidth(), GraphicsHeight(), 0, 0, 0, ImageBuffer(Img_RenderedWeapon)
  For w.Weapon = Each Weapon
    HideEntity w\ent
  Next
  ShowEntity WPiv
  ShowEntity BloodBall
  PositionEntity SkyBox, EntityX(Cam), EntityY(Cam), EntityZ(Cam)
  RenderWorld
  TranslateEntity Cam, 0, -1.7, 0

  DrawImage Img_RenderedWeapon, 0, WeaponTransPosition
  UpdateDisplay()
  Flip

  ;Mapchange/Finished
  If EntityX(Cam) > 95 And WeaponEnabled  Then Goto Chapter1
Wend
FreeWorld()
EndGraphics
Goto Menu
 
.Chapter1
Init()
PrepareGame(1)
Map = LoadMap_Office()
ChapterBegin(1)

;Equipment Pack
Equip = LoadMesh("Models\Equipment\Equipment.b3d")
ScaleEntity Equip, .3, .3, .3
PositionEntity Equip, -15.8, 2.2, -8
EntityParent Equip, WPiv

CreateSound(LoadSound("Sound\Cheaf\Chapter1.wav"))

;LevelSound
Snd_Beam = LoadSound("Sound\Beam.wav")

While Not KeyHit(1)
  hotug = Int(100 / fps)
  If hotug > 7 Then hotug = 7
  OldSelWeapon = SelWeapon
  For HowOftenToUpdateGame = 1 To hotug
    Gosub UpdateGame
    timer = (timer + 1) Mod 140
  Next

  ;Equipment Pack
  If WeaponEnabled = False Then
    If EntityDistance(Cam, Equip) < 3.5 Then
      CreateSound(Snd_GotItem)
      FreeEntity Equip
      WeaponEnabled = True
    EndIf
  EndIf
  If WeaponEnabled Then
    PositionEntity Piv1, -27.5, 30.6, -5.5
    If EntityDistance(Cam, Piv1) < 3 Then
      CreateSound(Snd_Beam)
      Cls
      Flip
      Delay 1000
      Goto Menu;;;;;;;;;;;
    EndIf
  EndIf

  ;FPS
  time# = MilliSecs()
  If time# - oldtime# <> 0 Then fps =  Int(1 / (time# - oldtime#) * 1000)
  If fps = 0 Then fps = 1
  oldtime# = MilliSecs()

  ;Render-System
  RenderSystem()

  DrawImage Img_RenderedWeapon, 0, WeaponTransPosition
  UpdateDisplay()
  Flip
Wend
FreeWorld()
EndGraphics
Goto Menu

.Chapter3
Init()
PrepareGame(3)
Map = LoadMap_Village()

ChapterBegin(3)

CreateSound(LoadSound("Sound\Cheaf\Chapter3.wav"))

While Not KeyHit(1)
  hotug = Int(100 / fps)
  If hotug > 7 Then hotug = 7
  OldSelWeapon = SelWeapon
  For HowOftenToUpdateGame = 1 To hotug
    Gosub UpdateGame
  Next

  ;FPS
  time# = MilliSecs()
  If time# - oldtime# <> 0 Then fps =  Int(1 / (time# - oldtime#) * 1000)
  If fps = 0 Then fps = 1
  oldtime# = MilliSecs()

  ;Render-System
  RenderSystem()

  DrawImage Img_RenderedWeapon, 0, WeaponTransPosition
  UpdateDisplay()
  Flip

  ;MapChange\Finished
  If AccMap$ = "Village" And EntityX(Cam) > 28 And EntityX(Cam) < 44 And EntityZ(Cam) < -160 And EntityZ(Cam) > -175 Then
    FreeEntity Map
    FreeMapBlockades()
    FreeKI()
    FreeMapMeshes()
    Map = LoadMap_Industry()
  EndIf
  If AccMap$ = "Industry" Then
    TranslateEntity Cam, 3, 0, 162
    If EntityX(Cam) > -7.8 And EntityX(Cam) < 3.8 And EntityY(Cam) > 0 And EntityY(Cam) < 10 And EntityZ(Cam) > -201.5 And EntityZ(Cam) < -191.5 Then Goto Chapter4
    TranslateEntity Cam, -3, 0, -162
  EndIf
Wend
FreeWorld()
EndGraphics
Goto Menu

.Chapter4
Init()
PrepareGame(4)

;LevelSound
Global Snd_EyeAttack1 =   LoadSound("Sound\Enemies\Eye\Attack1.wav")
Global Snd_EyeAttack2 =   LoadSound("Sound\Enemies\Eye\Attack2.wav")
Global Snd_EyeAttack3 =   LoadSound("Sound\Enemies\Eye\Attack3.wav")
Global Snd_EyeBlast1 =    LoadSound("Sound\Enemies\Eye\Blast1.wav")
Global Snd_EyeBlast2 =    LoadSound("Sound\Enemies\Eye\Blast2.wav")
Global Snd_EyeBlast3 =    LoadSound("Sound\Enemies\Eye\Blast3.wav")
Global Snd_EyeLaugh =     LoadSound("Sound\Enemies\Eye\Laugh.wav"): LoopSound Snd_EyeLaugh: CreateSound(Snd_EyeLaugh)
Global Snd_EyeDeath =     LoadSound("Sound\Enemies\Eye\Death.wav")

Map = LoadMap_Interior()
WeaponEnabled = True

ChapterBegin(4)

;Eye
Eye = LoadMesh("Models\Enemies\Eye.x")
EntityTexture Eye, LoadTexture("Models\Enemies\Eye.jpg")
ScaleEntity Eye, 115, 100, 100
EntityParent Eye, WPiv

eyef = 0
EyeHealth# = 100
framesinceeyedeath = 0

CreateSound(LoadSound("Sound\Cheaf\Chapter4.wav"))

While Not KeyHit(1)
  hotug = Int(100 / fps)
  If hotug > 7 Then hotug = 7
  OldSelWeapon = SelWeapon
  For HowOftenToUpdateGame = 1 To hotug
    Gosub UpdateGame
    ;Eye
    If EyeHealth# > 0 Then PositionEntity Eye, 23, Sin(MilliSecs() / 5) * 10 + 20, -50
    PointEntity Eye, Cam
    If eyewaitbeforeattack > 0 Then TurnEntity Eye, Rand(-10, 10), Rand(-10, 10), Rand(-10, 10)

    If EyeHealth# > 0 Then
      If EntityZ(Cam) < -20 Then
        eyef = (eyef + 1) Mod 230
        If eyef = 0 Then
          i = Rand(1, 3)
          Select i
            Case 1
              eyewaitbeforeattack = 100
              CreateSound(Snd_EyeAttack1)
            Case 2
              eyewaitbeforeattack = 160
              CreateSound(Snd_EyeAttack2)
            Case 3
              eyewaitbeforeattack = 160
              CreateSound(Snd_EyeAttack3)
          End Select
        EndIf
      EndIf
      eyewaitbeforeattack = Int(eyewaitbeforeattack) - 1
      If eyewaitbeforeattack = 0 Then
        i = Rand(1, 3)
        If i = 1 Then CreateSound(Snd_EyeBlast1)
        If i = 2 Then CreateSound(Snd_EyeBlast2)
        If i = 3 Then CreateSound(Snd_EyeBlast3)
        HaveToJump = True
        WalkXSpeed = Rand(-10, 10)
        WalkZSpeed = Rand(-10, 10)
        TurnEntity Cam, Rand(-180, 180), Rand(-180, 180), Rand(-180, 180)
        If EntityZ(Cam) < -32 Then Health# = Health# - Rand(70, 90): TimeSinceLastHit = 0 Else Health# = Health# - Rand(5, 10)
      EndIf
      For b.Bullet = Each Bullet
        If b\bullettype = 1 And EntityDistance(b\ent, Eye) < 4 Then EyeHealth# = EyeHealth# - .3: CreateBlood(EntityX(b\ent), EntityY(b\ent), EntityZ(b\ent), 1)
      Next
    Else
      If framesinceeyedeath = 0 Then
        For s.Sound = Each Sound
          StopChannel s\channel
          Delete s
        Next
      EndIf
      framesinceeyedeath = framesinceeyedeath + 1
      ScaleEntity Eye, Sin(MilliSecs() * Rand(1, 2)) * 160 + framesinceeyedeath, Cos(MilliSecs() * Rand(1, 2)) * 160 + framesinceeyedeath, Sin(MilliSecs() * Rand(1, 2)) * 160 + framesinceeyedeath
      CamShake# = 2
      If framesinceeyedeath = 150 Then CreateSound(Snd_EyeDeath)
      If framesinceeyedeath > 300 Then Goto EndMap
    EndIf
  Next

  ;FPS
  time# = MilliSecs()
  If time# - oldtime# <> 0 Then fps =  Int(1 / (time# - oldtime#) * 1000)
  If fps = 0 Then fps = 1
  oldtime# = MilliSecs()

  ;Render-System
  RenderSystem()

  DrawImage Img_RenderedWeapon, 0, WeaponTransPosition
  UpdateDisplay()
  SetFont GFont1
  If framesinceeyedeath > 300 Then Cls
  Flip
Wend
Goto Menu

.EndMap
ClearWorld
Init()

;LevelSound
Snd_Beam = LoadSound("Sound\Beam.wav")
;Temporary
WPiv = CreatePivot()

Map = LoadMap_EndMap()

;Camera
Cam = CreateCamera()
CameraRange Cam, .01, 1000
CameraFogMode Cam, True
CameraFogRange Cam, 0, 6
PositionEntity Cam, -1, .5, 0

fps = 100
CreateSound(Snd_Beam)
Repeat
  MoveEntity Cam, 0, 0, -1.0 / fps
  TurnEntity Cam, 0, 0, 65.0 / fps * (EntityZ(Cam) / 4.0)
  If EntityZ(Cam) < -6 Then
    CreateSound(Snd_Beam)
    Exit
  EndIf

  ;FPS
  time# = MilliSecs()
  If time# - oldtime# <> 0 Then fps =  Int(1 / (time# - oldtime#) * 1000)
  If fps = 0 Then fps = 1
  oldtime# = MilliSecs()

  ;Render-System
  RenderWorld
  Flip
  If KeyHit(1) Then Goto Outro
Forever
Cls

;Cheaf
Cheaf = CreateCube()
ScaleEntity Cheaf, .8, 1.9, .001
EntityTexture Cheaf, LoadTexture("Sprites\Cheaf.bmp", 4)
PositionEntity Cheaf, -.4, 1.9, 0
EntityColor Cheaf, 0, 0, 0

;Floor
FreeEntity Map
Floor = CreateCube()
ScaleEntity Floor, 10, .001, 10
FloorTex = LoadTexture("Maps\EndMap\Floor_Parkett.bmp")
ScaleTexture FloorTex, .1, .1
EntityTexture Floor, FloorTex, 0, 0
EntityColor Floor, 0, 0, 0

;Camera
PositionEntity Cam, 0, 2, -5
RotateEntity Cam, 0, 0, 0
CameraFogRange Cam, 0, 10

;LevelSound
Snd_LightOn = LoadSound("Sound\Light_On.wav")
Snd_CheafStep = LoadSound("Sound\Cheaf\Step.wav")
Snd_Breathe = LoadSound("Sound\Player\Breathe.wav")

scenario1_happend = False
cheaf_stepcnt = 0

fps = 100
CreateSound(Snd_Breathe)
While Not KeyHit(1)
  frame = frame + 1
  If frame > 300 And scenario1_happend = False Then
    scenario1_happend = True
    EntityColor Floor, 255, 255, 255
    EntityTexture Floor, LoadTexture("Sprites\LM.bmp"), 0, 1
    Flare = LoadSprite("Sprites\Flare.bmp")
    PositionEntity Flare, -.2, 2.9, -2
    CreateSound(Snd_LightOn)
    EntityColor Cheaf, 150, 150, 100
  EndIf
  cheaf_stepcnt = cheaf_stepcnt + 1
  If Right$(Str$(cheaf_stepcnt), 2) = "00" And frame < 300 Then CreateSound(Snd_CheafStep)
  PointEntity Cheaf, Cam

  ;Render-System
  RenderWorld
  Flip
Wend

.Outro
FreeWorld()

Graphics 1024, 768, 32, 1
SetBuffer BackBuffer()

For i = 1 To 11
  presents[i] = LoadImage("Gfx\Outro" + i + ".jpg")
Next

pos# = GraphicsHeight()
SndC = PlaySound(LoadSound("Sound\Ui\Outro.mp3"))
ChannelVolume SndC, Cfg_SoundVolume

ms = MilliSecs()

fps = 1
While Not KeyHit(1)
  If MilliSecs() - ms => 99000 Then Exit
  Cls
  pos = pos - 20.0 / fps
  mp = 0
  For i = 1 To 11
    If pos + mp > -ImageHeight(presents[i]) Then DrawImage presents[i], GraphicsWidth() / 2 - ImageWidth(presents[i]) / 2, pos + mp
    mp = mp + ImageHeight(presents[i]) + 55
  Next

  ;FPS
  time# = MilliSecs()
  If time# - oldtime# <> 0 Then fps =  Int(1 / (time# - oldtime#) * 1000)
  If fps = 0 Then fps = 1
  oldtime# = MilliSecs()

  Flip
Wend
StopChannel SndC
Goto MenuWithoutGraphics

Function DefaultSettings()
Cfg_Width = 800
Cfg_Height = 600
Cfg_InvMouse = False
Cfg_Crossair = True
Cfg_MouseSensity = 1
Cfg_Sound = True
Cfg_SoundVolume = 1
End Function

Function RenderSystem()
TranslateEntity Cam, 0, 1.7, 0
HideEntity Wpiv
HideEntity BloodBall
RenderWorld
CopyRect 0, 0, GraphicsWidth(), GraphicsHeight(), 0, 0, 0, ImageBuffer(Img_RenderedWeapon)
For w.Weapon = Each Weapon
  HideEntity w\ent
Next
ShowEntity WPiv
ShowEntity BloodBall
PositionEntity SkyBox, EntityX(Cam), EntityY(Cam), EntityZ(Cam)
RenderWorld
TranslateEntity Cam, 0, -1.7, 0
End Function


~Editiert~
Bei solchen langen Codes bitte die [ code ] Tags benutzen. Sonst lädt er viel zu lange. MfG D2006

D2006

Administrator

BeitragFr, Sep 02, 2005 12:50
Antworten mit Zitat
Benutzer-Profile anzeigen
Die Funktion Init() wäre mal noch interessant.
Ich nehm an, du hast vergessen nach dem Graphics3D den Buffer auf BackBuffer zu schalten, wie bei diesem Code in Zeile 285 unter der Sprungmarke .FreeLook.

Gewöhn dir mal bitte Funktionen an. Für die Zukunft.

MfG
D2006

Devils Child

BeitragFr, Sep 02, 2005 13:18
Antworten mit Zitat
Benutzer-Profile anzeigen
das ist die funktion init:
BlitzBasic: [AUSKLAPPEN]
Function Init()
FreeWorld()
Graphics3D Cfg_Width, Cfg_Height, 32, 1
SetBuffer BackBuffer()
Dither True
HidePointer
SeedRnd MilliSecs()
End Function

Function FreeWorld()
For i.Bullet = Each Bullet: Delete i: Next
For b.Blood = Each Blood: Delete b: Next
For c.CarTridge = Each CarTridge: Delete c: Next
For d.DecalSpliter = Each DecalSpliter: Delete d: Next
For ds.DecalSpark = Each DecalSpark: Delete ds: Next
For e.Explosion = Each Explosion: Delete e: Next
For ca.Catapult = Each Catapult: Delete ca: Next
For m.MapBlockade = Each MapBlockade: Delete m: Next
For mm.MapMesh = Each MapMesh: Delete mm: Next
For g.Grenade = Each Grenade: Delete g: Next
For w.Weapon = Each Weapon: Delete w: Next
For s.Sound = Each Sound
StopChannel s\channel
Delete s
Next
ClearWorld
End Function
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN
 

Apocalyptic

BeitragFr, Sep 02, 2005 15:20
Antworten mit Zitat
Benutzer-Profile anzeigen
Kein Print im Zusammenhang mit DoubleBuffering verwenden!
Code: [AUSKLAPPEN]
While Not KeyHit(1)
  ;Walking
  Sp# = .05
  If KeyDown(42) Then Sp# = Sp# * 2
  If KeyDown(17) Then ZSpeed# = ZSpeed# + Sp#
  If KeyDown(31) Then ZSpeed# = ZSpeed# - Sp#
  If KeyDown(30) Then XSpeed# = XSpeed# - Sp#
  If KeyDown(32) Then XSpeed# = XSpeed# + Sp#
  XSpeed# = XSpeed# * .9
  ZSpeed# = ZSpeed# * .9
  MoveEntity Cam, XSpeed, 0, ZSpeed#

  ;FPS
  time# = MilliSecs()
  If time# - oldtime# <> 0 Then fps =  Int(1 / (time# - oldtime#) * 1000)
  If fps = 0 Then fps = 1
  oldtime# = MilliSecs()

  Locate  1, 100
  Print "Camera Position:"
  Print "----------------"
  Print "X: " + EntityX(Cam)
  Print "Y: " + EntityY(Cam)
  Print "Z: " + EntityZ(Cam)

  UpdateCatapults(Cam)

  MouseLook(Cam)
  PositionEntity SkyBox, EntityX(Cam), EntityY(Cam), EntityZ(Cam)
  RenderWorld
  Flip
Wend

Nimm ql:text
Suum cuique

[ www.ffs-net.de.vu ] [ Raycaster ]
  • Zuletzt bearbeitet von Apocalyptic am Fr, Sep 02, 2005 15:23, insgesamt 3-mal bearbeitet

Gehe zu Seite 1, 2  Weiter

Neue Antwort erstellen


Übersicht BlitzBasic Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group