Verfasst: 10.06.2009 00:09
Engine3D braucht man auch für die Window3D-Lib... 

Das deutsche PureBasic-Forum
https://www.purebasic.fr/german/
Aber man braucht sie doch nich für ein 2D-GameKaeru Gaman hat geschrieben:Engine3D braucht man auch für die Window3D-Lib...
Code: Alles auswählen
; Win
; Engine
; Copyright (C) Tur0k
; Fixes by KeyKon
UsePNGImageDecoder()
; WindowMouseX(0)
;ohne Screen immer GetAsyncKeyState_(#Button) verwenden.
;(Linke Maustaste: #VK_LBUTTON, rechte: #VK_RBUTTON)
If InitSprite() = 0 Or InitKeyboard() = 0
MessageRequester("Error", "Can't open the sprite system", 0)
End
EndIf
If InitSprite3D() = 0
MessageRequester("Error", "Sprite3D system can't be initialized correctly", 0)
End
EndIf
PlayerX = 1
PlayerY = 1
WandX = 50
WandY = 50
menubox = 0
Enumeration ;Sprites
#Sp_Map
#Sp_Wand
#Sp_Cursor
#Sp_MiniBox
EndEnumeration
Structure sp
sid.l
s3did.l
EndStructure
Dim Figur.sp(3)
If OpenWindow(0, 0, 0, 400, 400, "Turoks Engine", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0), 0, 0, 400, 400, 0, 0, 0)
Sprite3DQuality(#PB_Sprite3D_BilinearFiltering)
LoadSprite(#Sp_MiniBox, "mini_box.png", #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
CreateSprite3D(#Sp_MiniBox, #Sp_MiniBox)
LoadSprite(#Sp_Cursor, "cursor.png", #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
CreateSprite3D(#Sp_Cursor, #Sp_Cursor)
LoadSprite(#Sp_Map, "map_01.png", #PB_Sprite_Texture)
CreateSprite3D(#Sp_Map, #Sp_Map)
LoadSprite(#Sp_Wand, "wand.png", #PB_Sprite_Texture)
CreateSprite3D(#Sp_Wand, #Sp_Wand)
For x = 0 To 3
Figur(x)\sid = LoadSprite(#PB_Any,"person"+Str(x+1)+".png",#PB_Sprite_Texture)
Figur(x)\s3did = CreateSprite3D(#PB_Any,Figur(x)\sid)
Next
EndIf
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
End
EndIf
Repeat
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Event = 0
ExamineKeyboard()
If GetAsyncKeyState_(#VK_RBUTTON)
DispBox = 1
Else
DispBox = 0
EndIf
Delay(5)
; ------------------------------------------------
ClearScreen(RGB(0,0,0))
; ------------------------------------------------
If Start3D()
DisplaySprite3D(#Sp_Map, 0, 0)
DisplaySprite3D(#Sp_Wand, WandX, WandY)
DisplaySprite3D(Figur(way)\s3did, PlayerX, PlayerY)
If WindowMouseX(0) > -1
DisplaySprite3D(#Sp_Cursor, WindowMouseX(0)-12, WindowMouseY(0)-12)
EndIf
If DispBox
DisplaySprite3D(#Sp_MiniBox, WindowMouseX(0)-55, WindowMouseY(0)+15)
EndIf
Stop3D()
EndIf
; ------------------------------------------------
If KeyboardPushed(#PB_Key_W) And PlayerY > 0
PlayerY-1
way = 3
If SpriteCollision(Figur(way)\sid,PlayerX,PlayerY,#Sp_Wand,WandX,WandY)
PlayerY+1
EndIf
EndIf
; ------------------------------------------------
If KeyboardPushed(#PB_Key_S) And PlayerY < 356
PlayerY +1
way = 0
If SpriteCollision(Figur(way)\sid,PlayerX,PlayerY,#Sp_Wand,WandX,WandY)
PlayerY-1
EndIf
EndIf
; ------------------------------------------------
If KeyboardPushed(#PB_Key_A) And PlayerX > 0
PlayerX -1
way = 2
If SpriteCollision(Figur(way)\sid,PlayerX,PlayerY,#Sp_Wand,WandX,WandY)
PlayerX+1
EndIf
EndIf
; ------------------------------------------------
If KeyboardPushed(#PB_Key_D) And PlayerX < 379
PlayerX +1
way = 1
If SpriteCollision(Figur(way)\sid,PlayerX,PlayerY,#Sp_Wand,WandX,WandY)
PlayerX-1
EndIf
EndIf
SetWindowTitle(0, "Spieler Position: " + "X: " + Str(PlayerX) + " " + " Y: " + Str(PlayerY) + " " + "Mouse X: " + Str(WindowMouseX(0)) + " " + " Mouse Y: " + Str(WindowMouseY(0)))
If StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Transparent)
BackColor(RGB(0,155,155)) ; Change the text back and front colour
FrontColor(RGB(255,255,255))
If DispBox
DrawText(WindowMouseX(0)-44, WindowMouseY(0)+23,"This is a test")
EndIf
StopDrawing()
EndIf
FlipBuffers()
; ------------------------------------------------
Until Quit Or KeyboardPushed(#PB_Key_Escape)
Hä? Also bei mir nich...Tur0k hat geschrieben:Kleiner Fehler, wenn man die Taste S klickt, wird die Map (Bild) bewegt.