It is currently Fri May 24, 2013 3:13 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: reversed colours
PostPosted: Sat Jun 09, 2012 2:14 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri May 25, 2012 7:39 pm
Posts: 183
Hey guys,
I've got a question: Imagine you had an image that has a " + " shape and you want to do the folloing thing: it's a 2D image, but the actual game is in 3D. You want the image to be translucent AND have the reversed colour of what can be seen through it. HOW do I do that? I really have no idea how to do all that...I hope anyone can help me. Thanks in advance :)


Top
 Profile  
 
 Post subject: Re: reversed colours
PostPosted: Sat Jun 09, 2012 4:01 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 2401
Location: Utah, USA
Assuming you will not be drawing over a previously drawn image, try drawing a white cross using 'DrawingMode(#PB_2DDrawing_XOr)'.

_________________
Image


Top
 Profile  
 
 Post subject: Re: reversed colours
PostPosted: Sat Jun 09, 2012 4:06 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri May 25, 2012 7:39 pm
Posts: 183
Ah, thank you! great idea!
Do you also know how to reverse the colours? like if a blue item is in the background, you see it in orange looking through the cross?


Top
 Profile  
 
 Post subject: Re: reversed colours
PostPosted: Sat Jun 09, 2012 7:08 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri May 25, 2012 7:39 pm
Posts: 183
Okayyyyy I've got another problem: I have that cross...and all the 2D stuff...But nothing in 3D anymore :'( I'm using all the commands for a "world". I hope someone can help :/


Top
 Profile  
 
 Post subject: Re: reversed colours
PostPosted: Sat Jun 09, 2012 7:19 pm 
Offline
Addict
Addict

Joined: Sun Dec 12, 2010 12:36 am
Posts: 1284
Location: Waterloo, WI - USA
Maybe some code showing what you've done / are trying to do is in order.

_________________
Image


Top
 Profile  
 
 Post subject: Re: reversed colours
PostPosted: Sat Jun 09, 2012 7:28 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri May 25, 2012 7:39 pm
Posts: 183
Code:

Code:
Procedure SpecialFXCross ()
width = (DesktopWidth (0) / 2) - (TextWidth (Str(SpeedX) + "                " + Str (SpeedZ)) / 2)
height = (DesktopHeight (0) / 2) - (TextHeight (Str(SpeedX) + "                " + Str (SpeedZ)) / 2)

StartSpecialFX ()

DrawingMode (#PB_2DDrawing_XOr)     
DisplaySprite (0,width,height)

StopSpecialFX ()
EndProcedure

If InitEngine3D ()
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops ()
OpenScreen (DesktopWidth (0),DesktopHeight (0),DesktopDepth (0),"NAVY")
EX = 0
EZ = 0
zieg.s = GetPathPart (ProgramFilename())
UsePNGImageDecoder ()
LoadSprite (0,zieg + "Cross.png",#PB_Sprite_Memory )
Add3DArchive(zieg, #PB_3DArchive_FileSystem) ; C:\Program Files (x86)\MyCompany\MyApplication\
Parse3DScripts()

LoadMesh   (0, "Battleship.mesh")
LoadMesh   (1, "Ground.mesh")
LoadMesh   (2, "Stealth 01.mesh")




LoadFont (0,"Arial",20)
LoadFont (1,"Arial",10)
LoadFont (2, "Arial",40)

Black = RGB (0,0,0)
White = RGB (255,255,255)
Font1Colour = White
Font1ColourBk = Black
Font2Colour =White
Font2ColourBk = Black
Font3Colour = White
Font2ColourBk = Black
Font4Colour = White
Font4ColourBk = Black

Repeat
If IsScreenActive ()
ClearScreen (0)
ExamineKeyboard ()
ExamineMouse ()

StartDrawing (ScreenOutput ())
DrawingFont (FontID(0))
DrawText (200,200,"NAVY",RGB(255,255,255),0)
DrawingFont (FontID(1))
DrawText (300,250,"New Game",Font1Colour,Font1ColourBk)
DrawText (319,280, "Play",Font2Colour,Font2ColourBk)
DrawText (308,310,"Options",Font3Colour,Font3ColourBk)
DrawText (319,340, "Quit",Font4Colour,Font4ColourBk)
DrawText (20,30,Str (MouseX ()) + "    " + Str (MouseY ()),255,0)
Box (MouseX (), MouseY (), 3,3,255)
StopDrawing ()

If MouseX () > 298 And MouseX () < 364 And MouseY () > 250 And MouseY () < 270
Font1Colour = Black
Font1ColourBk = White
Covered = 1
Else
Font1Colour = White
Font1ColourBk = Black
EndIf

If MouseX () > 300 And MouseX () < 363 And MouseY () > 280 And MouseY () < 300
Font2Colour = Black
Font2ColourBk = White
Covered = 2
Else
Font2Colour = White
Font2ColourBk = Black
EndIf

If MouseX () > 300 And MouseX () < 363 And MouseY () > 310 And MouseY () < 330
Font3Colour = Black
Font3ColourBk = White
Covered = 3
Else
Font3Colour = White
Font3ColourBk = Black
EndIf

If MouseX () > 300 And MouseX () < 363 And MouseY () > 340 And MouseY () < 360
Font4Colour = Black
Font4ColourBk = White
Covered = 4
Else
Font4Colour = White
Font4ColourBk = Black
EndIf

If Covered = 1 And MouseButton (1) And checker < 1
checker = 100
Gosub NewGame
ElseIf Covered = 0 And MouseButton (1)
EndIf
If Covered = 2 And MouseButton (1) And checker < 1
checker = 100
Gosub Game
ElseIf Covered = 0 And MouseButton (1)
EndIf
If Covered = 3 And MouseButton (1) And checker < 1
checker = 100
Gosub Options
ElseIf Covered = 0 And MouseButton (1)
EndIf
If Covered = 4 And MouseButton (1) And checker < 1
checker = 100
Gosub Ending
ElseIf Covered = 0 And MouseButton (1)
EndIf

Else
Delay (20)
;StopSound (-1)
EndIf
FlipBuffers ()
Until KeyboardPushed (1)



;-Ending
Ending:
End
Return
















NewGame:







;-Modus
Black = RGB (0,0,0)
White = RGB (255,255,255)
Font1Colour = White
Font1ColourBk = Black
Font2Colour =White
Font2ColourBk = Black
Font3Colour = White
Font2ColourBk = Black
Font4Colour = White
Font4ColourBk = Black

Repeat
If IsScreenActive ()
ClearScreen (0)
ExamineKeyboard ()
ExamineMouse ()

StartDrawing (ScreenOutput ())
DrawingFont (FontID(0))
DrawText (200,200,"NAVY",RGB(255,255,255),0)
DrawingFont (FontID(1))
DrawText (300,250,"Ship mode",Font1Colour,Font1ColourBk)
DrawText (319,280, "Airforce mode",Font2Colour,Font2ColourBk)
DrawText (308,310,"Options",Font3Colour,Font3ColourBk)
DrawText (319,340, "Quit",Font4Colour,Font4ColourBk)
DrawText (20,30,Str (MouseX ()) + "    " + Str (MouseY ()),255,0)
Box (MouseX (), MouseY (), 3,3,255)
StopDrawing ()

If checker > 0
checker - 1
EndIf

If MouseX () > 298 And MouseX () < 364 And MouseY () > 250 And MouseY () < 270
Font1Colour = Black
Font1ColourBk = White
Covered = 1
Else
Font1Colour = White
Font1ColourBk = Black
EndIf

If MouseX () > 300 And MouseX () < 363 And MouseY () > 280 And MouseY () < 300
Font2Colour = Black
Font2ColourBk = White
Covered = 2
Else
Font2Colour = White
Font2ColourBk = Black
EndIf

If MouseX () > 300 And MouseX () < 363 And MouseY () > 310 And MouseY () < 330
Font3Colour = Black
Font3ColourBk = White
Covered = 3
Else
Font3Colour = White
Font3ColourBk = Black
EndIf

If MouseX () > 300 And MouseX () < 363 And MouseY () > 340 And MouseY () < 360
Font4Colour = Black
Font4ColourBk = White
Covered = 4
Else
Font4Colour = White
Font4ColourBk = Black
EndIf

If Covered = 1 And MouseButton (1) And checker < 1
Gosub Shipmode
ElseIf Covered = 0 And MouseButton (1)
EndIf
If Covered = 2 And MouseButton (1) And checker < 1
Gosub Aircraftmode
ElseIf Covered = 0 And MouseButton (1)
EndIf
If Covered = 3 And MouseButton (1) And checker < 1
Gosub Options
ElseIf Covered = 0 And MouseButton (1)
EndIf
If Covered = 4 And MouseButton (1) And checker < 1
Gosub Ending
ElseIf Covered = 0 And MouseButton (1)
EndIf

Else
Delay (20)
;StopSound (-1)
EndIf
FlipBuffers ()
Until KeyboardPushed (1)
End







































Shipmode: ;-Shipmode




CreateMaterial(0, LoadTexture(0, "Battleship.material"))
CreateEntity (0,MeshID (0),#PB_Material_None,10,10,10)
CopyEntity (0,1)
CreateEntity (1,MeshID (2),MaterialID (0),-20,-200,-50)
EntityLocate (1,5000,10,0)
#CameraSpeed = 10
skydome = SkyDome ("SkyNAVY.jpg",30)
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0,x,y,100)
EnableWorldPhysics (1)
      WorldGravity (9.806)
      EntityPhysicBody (0,#PB_Entity_SphereBody)
      SetEntityMass (0,30)
      EntityPhysicBody (1,#PB_Entity_SphereBody)
      SetEntityMass (1,30)
      EntityPhysicBody (2,#PB_Entity_StaticBody)
      SetEntityFriction (2,5)
      SetEntityMass (2,-30)
EnableWorldCollisions(1)


If skydome
Repeat
ClearScreen(RGB(0, 0, 0))
ExamineKeyboard()
ExamineMouse()
SpeedX = 0
SpeedZ = 0


        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed
        Else
          KeyX = 0
        EndIf
                 
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed
        Else
          KeyY = 0
        EndIf
       
If KeyboardPushed(#PB_Key_U)
          SpeedZ = -1
          RotateEntity(0, 0, 90, 0)
        ElseIf KeyboardPushed(#PB_Key_J)
          SpeedZ = 1
       RotateEntity(0, 0, 270, 0)
        EndIf

If KeyboardPushed(#PB_Key_H)
          SpeedX = -1
          RotateEntity (0,0,180,0)
        ElseIf KeyboardPushed(#PB_Key_K)
          SpeedX = 1
          RotateEntity(0, 0, 0, 0)
        EndIf
       
MoveEntity(0, SpeedX*3, 0, SpeedZ*3)

MouseX = -MouseDeltaX()/10
MouseY = -MouseDeltaY()/10
RotateCamera(0, MouseX, MouseY, RollZ)
MoveCamera  (0, KeyX, 0, KeyY)
;CameraLookAt(0, EntityX(0), EntityY(0), EntityZ(0))
;If ExamineWorldCollisions()
       
 ;        While NextWorldCollision()

  ;          If FirstWorldCollisionEntity() = 0 Or SecondWorldCollisionEntity() = 0
               
             

   ;             HideEntity(0, 1)
    ;            If SpeedX<0   
     ;             MoveEntity(0, 700, 0, 0)         
     ;           ElseIf SpeedX>0
     ;             MoveEntity(0, -700, 0, 0)
      ;          EndIf

    ;            If SpeedZ<0
     ;             MoveEntity(0, 0, 0, 700)
      ;          ElseIf SpeedZ>0
       ;           MoveEntity(0, 0, 0, -700)
       ;         EndIf
;                HideEntity(0, 0)
;            EndIf
;           
;         Wend
;      EndIf
     
RenderWorld ()

StartDrawing (ScreenOutput ())
DrawingMode (#PB_2DDrawing_Transparent)
width = (DesktopWidth (0) / 2) - (TextWidth (Str(SpeedX) + "                " + Str (SpeedZ)) / 2)
height = (DesktopHeight (0) / 2) - (TextHeight (Str(SpeedX) + "                " + Str (SpeedZ)) / 2)
DrawingFont (FontID (2))
DrawText (width,height,"+",255,0)
DrawingFont (FontID (1))
DrawText (20,260,Str(EntityX(0)) + "                " + Str (EntityZ (0)),255,0)
DrawText (200,260,Str (Engine3DFrameRate(#PB_Engine3D_Current)),255,0)
StopDrawing ()
FlipBuffers ()
Until KeyboardPushed (1)
EndIf

EndIf
End
Return























Aircraftmode: ;-Aircraftmode




CreateMaterial(1, LoadTexture(1, "Stealth 01.material"))
CreateEntity (3,MeshID (2),#PB_Material_None,10,10,10)
CopyEntity (3,4)
EntityLocate (4,5000,10,0)
#CameraSpeed = 10
skydome = SkyDome ("SkyNAVY.jpg",30)
CreateCamera(1, 0, 0, 100, 100)
CameraLocate(1,x,y,100)
EnableWorldPhysics (1)
      WorldGravity (9.806)
      EntityPhysicBody (3,#PB_Entity_SphereBody)
      SetEntityMass (3,30)
      EntityPhysicBody (4,#PB_Entity_SphereBody)
      SetEntityMass (4,30)
EnableWorldCollisions(1)


If skydome
Repeat

ClearScreen(RGB(0, 0, 0))
ExamineKeyboard()
ExamineMouse()
SpeedX = 0
SpeedZ = 0


        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed
        Else
          KeyX = 0
        EndIf
                 
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed
        Else
          KeyY = 0
        EndIf
       
If KeyboardPushed(#PB_Key_U)
          SpeedZ = -1
          RotateEntity(3, 0, 90, 0)
        ElseIf KeyboardPushed(#PB_Key_J)
          SpeedZ = 1
       RotateEntity(3, 0, 270, 0)
        EndIf

If KeyboardPushed(#PB_Key_H)
          SpeedX = -1
          RotateEntity (3,0,180,0)
        ElseIf KeyboardPushed(#PB_Key_K)
          SpeedX = 1
          RotateEntity(3, 0, 0, 0)
        EndIf
       
MoveEntity(3, SpeedX*3, 0, SpeedZ*3)

MouseX = -MouseDeltaX()/10
MouseY = -MouseDeltaY()/10
RotateCamera(1, MouseX, MouseY, RollZ)
MoveCamera  (1, KeyX, 0, KeyY)
RenderWorld ()

SpecialFXCross ()

StartDrawing (ScreenOutput ())
DrawingMode (#PB_2DDrawing_Transparent)

DrawingFont (FontID (2))
;DrawText (width,height,"+",255,0)
DrawingFont (FontID (1))
DrawText (20,260,Str(EntityX(0)) + "                " + Str (EntityZ (0)),255,0)
DrawText (200,260,Str (Engine3DFrameRate(#PB_Engine3D_Current)),255,0)

StopDrawing ()
FlipBuffers ()
Until KeyboardPushed (1)
EndIf



End
Return











Return





Game:
Return


Options:
Return


This code is in a quite early state of development


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye