DisplaySprite3D weird??

Advanced game related topics
cbmeeks
User
User
Posts: 17
Joined: Tue Dec 23, 2003 5:33 pm

DisplaySprite3D weird??

Post by cbmeeks »

Hello. Newbie here.

When I draw my 3d Sprite and it passes the screen boundries, I get a funny line across the top??

Anyone know how to prevent this? (Other than limiting the positions)

Thanks!

cb
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Could you please show us some code ???
cbmeeks
User
User
Posts: 17
Joined: Tue Dec 23, 2003 5:33 pm

Post by cbmeeks »

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Sprite example file
;
;    (c) 2002 - Fantaisie Software
;
; ------------------------------------------------------------
;

If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
  MessageRequester("Error", "Can't open DirectX 7 Or later", 0)
  End
EndIf

If InitSprite3D() = 0
  MessageRequester("Error", "Direct3D system can't be initialized correctly", 0)
  End
EndIf


;
; Now, open a 640*480 - 16 bits (65000 colours) screen
;

If OpenScreen(640, 480, 16, "Sprite")

    ;load sprites
    UsePNGImageDecoder()
    LoadSprite(0, "Room.PNG", 0)
    TransparentSpriteColor(0, 255, 0, 255) ; Our pink is transparent :)
    
    LoadSprite(1, "Lava.png", #PB_Sprite_Texture)
    TransparentSpriteColor(1, 255, 0, 255)
    
    LoadSprite(2, "kraid_single.png", #PB_Sprite_Texture)
    TransparentSpriteColor(2, 255, 0, 255)
    
    ;convert sprites to 3D
    CreateSprite3D(1,1)
    CreateSprite3D(2,2)

    ;set sprite quality
    Sprite3DQuality(0)
  
    ;variables
    lx = 480-192
    lxd = 1


    ;MAIN LOOP

    Repeat
    
        ; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back)
        FlipBuffers()


        ;draw background
        DisplaySprite(0,0,0)

        
        ;update mouse info
        ExamineMouse()

        ; Draw our sprite
        If Start3D()
            DisplaySprite3D(2, MouseX(), MouseY(), 255)
            DisplaySprite3D(1, 0, lx, 128)
            Stop3D()
        EndIf
        
        ;update keyboard info
        ExamineKeyboard()
        
        ;updates
        lx = lx + lxd
        If lx < 480-192 Or lx > 480
            lxd = -lxd
        EndIf

        r = r + 1
        If r > 359
            r = 0
        EndIf
        
    Until KeyboardPushed(#PB_Key_Escape)
  
Else        ;ERROR!
    MessageRequester("Error", "Can't open a 640*480 - 16 bit screen !", 0)
EndIf

End   
As you can see, this is a modified example.

Thanks

cb
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Ok... I've runned it and had no problem...

But i used BMP instead of PNG... Also i changes the code a bit...

Code: Select all

; 
; ------------------------------------------------------------ 
; 
;   PureBasic - Sprite example file 
; 
;    (c) 2002 - Fantaisie Software 
; 
; ------------------------------------------------------------ 
; 

If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0 
  MessageRequester("Error", "Can't open DirectX 7 Or later", 0) 
  End 
EndIf 

If InitSprite3D() = 0 
  MessageRequester("Error", "Direct3D system can't be initialized correctly", 0) 
  End 
EndIf 


; 
; Now, open a 640*480 - 16 bits (65000 colours) screen 
; 

If OpenScreen(640, 480, 16, "Sprite") 
  
  ;load sprites 
  UsePNGImageDecoder() 
  LoadSprite(0, "gfx\text00.bmp", 0) 
  TransparentSpriteColor(0, 255, 0, 255) ; Our pink is transparent :) 
  
  LoadSprite(1, "gfx\text02.bmp", #PB_Sprite_Texture) 
  TransparentSpriteColor(1, 255, 0, 255) 
  
  LoadSprite(2, "gfx\text03.bmp", #PB_Sprite_Texture) 
  TransparentSpriteColor(2, 255, 0, 255) 
  
  ;convert sprites to 3D 
  CreateSprite3D(1,1) 
  CreateSprite3D(2,2) 
  
  ;set sprite quality 
  Sprite3DQuality(0) 
  
  ;variables 
  lx = 480-192 
  lxd = 1 
  
  
  ;MAIN LOOP 
  
  Repeat 
    
     ; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back) 
    FlipBuffers()  
    
    ClearScreen(0,0,0)   
    
    ;draw background 
    DisplaySprite(0,0,0) 
    
    
    ;update mouse info 
    ExamineMouse() 
    
    ; Draw our sprite 
    If Start3D() 
      DisplaySprite3D(2, MouseX(), MouseY(), 255) 
      DisplaySprite3D(1, 0, lx, 128) 
      Stop3D() 
    EndIf 
    
    ;updates 
    lx = lx + lxd 
    If lx < 480-192 Or lx > 480 
      lxd = -lxd 
    EndIf 
    
    r  + 1 
    If r > 359 
      r = 0 
    EndIf 
    

    
    ;update keyboard info 
    ExamineKeyboard() 
    
  Until KeyboardPushed(#PB_Key_Escape) 
  
Else        ;ERROR! 
  MessageRequester("Error", "Can't open a 640*480 - 16 bit screen !", 0) 
EndIf 

End   
Post Reply