How can I use sprites on a normal window ?

Mac OSX specific forum
User avatar
LESTROSO
Enthusiast
Enthusiast
Posts: 124
Joined: Thu Nov 03, 2005 12:30 pm
Location: Italy
Contact:

How can I use sprites on a normal window ?

Post by LESTROSO »

I'm very happy to communicate you, that i've finished my tic tac toe for mac, but i have a problem.... :(

If i want make an background image and then push the image "x"or "o" like sprites, how i can make it??

Or better, when i push on a box, it compare a "X" or "o" and than the image appear on the background.....

ok but in a window i have used "open windowedscreen(...........)but it's not working is correct or not??

Could anyone help me?

Many thanks...... :D
Fred
Administrator
Administrator
Posts: 16688
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Please don't use uppercase letter for the title, it makes it a bit aggressive. To use sprite on a window, you will have to do it in a 'Windowed Screen' as you have tried. It should work ok, do you have any small code to test ?
User avatar
LESTROSO
Enthusiast
Enthusiast
Posts: 124
Joined: Thu Nov 03, 2005 12:30 pm
Location: Italy
Contact:

Post by LESTROSO »

i'm so sorry fred ,i'm always forget the uppercase :oops:



;
; ------------------------------------------------------------
;
; PureBasic - Window-Mac os x - Tic Tac Toe
;
; (c) 2005/6 - Fasa Software - Versione 5.5
;
; ------------------------------------------------------------
;-load the decoder

InitMovie()
UseJPEGImageDecoder()
UseOGGSoundDecoder()
InitSound()

Code: Select all

 
 
InitSprite()

;OpenWindow(0,0,0,275,400,#PB_Window_SystemMenu|;#PB_Window_ScreenCentere;d,"Tris-Game") And CreateGadgetList(WindowID(0))
 
 OpenWindowedScreen(0,0,0,275,400,1,1,1)
 

If CreateGadgetList(WindowID())
If CreateMenu(0, WindowID())
MenuItem(#PB_Menu_About,"About who made the program?"+ Chr(9) + "CMD+A")
MenuItem(#PB_Menu_Quit, "Quit" + Chr(9) + "CMD+Q")
EndIf

#ResourceFolder = "Resources/"
;#ResourceFolder = "/Users/capitan/desktop/tris/Resource/"
;-carico le risorse

CatchImage(32,?1)

Code: Select all

 

 CatchSprite(19,?faccia)
 

CatchImage(20,?x)
CatchImage(30,?0)
CatchImage(31,?about)
P14 = LoadMovie(#PB_Any,#Resourcefolder+"campane.mp3")
P15 = LoadMovie(#PB_Any,#Resourcefolder+"boink.mp3")
P16 = LoadMovie(#PB_Any,#Resourcefolder+"pop.mp3")
P17 = LoadMovie(#PB_Any,#Resourcefolder+"risata.mp3")
P18 = LoadMovie(#PB_Any,#Resourcefolder+"appl.mp3")
P32 = LoadMovie(#PB_Any,#Resourcefolder+"about.mp3")


;-costruisco la finestra con i gadget

TextGadget(10,12,280,250,20," Select level and then Push start button!!")
OptionGadget(11, 85, 317, 60, 20, "Easy")
OptionGadget(12, 150, 317, 60, 20, "Hard")
ButtonGadget(13, 35, 350, 200, 20, "Let's start!!")
EndIf

;- seleziono il livello
Start:
livello=0
vittoria=0
SceltaFatta=0
click=0
numero=0
statocella1=0
statocella2=0
statocella3=0
statocella4=0
statocella5=0
statocella6=0
statocella7=0
statocella8=0
statocella9=0
ContaMosse=0
DisableGadget(11,0)
DisableGadget(12,0)
DisableGadget(13,0)
SetGadgetState(11,1)

ActivateGadget(13)
livello=1


Repeat

ActivateWindow()
EventID = WaitWindowEvent()

If EventID = #PB_EventMenu
Select EventMenuID()

Case #PB_Menu_Quit : Quit = 2
Case #PB_Menu_About
OpenWindow(32,230,95,335,400,#PB_Window_TitleBar,"ABOUT")


CreateGadgetList(WindowID(32))
UseWindow(32)
ButtonGadget(33, 26, 360,280, 30, "Ok, Go back to the game")

ImageGadget(31,0,0,100,83,UseImage(31))
PlayMovie(P32,0)

EndSelect
EndIf

If EventID = #PB_EventGadget

Select EventGadgetID()

Case 12
ActivateGadget(13)
livello=2
Case 13

PlayMovie(P14,0)

If livello<>0
Goto game
EndIf
Case 33
StopMovie()
CloseWindow(32)
UseWindow(0)
UseGadgetList(WindowID(0))
EndSelect

EndIf

Until Quit=2 Or EventID = #PB_Event_CloseWindow
End

Code: Select all

 
 
game:
;OpenWindowedScreen(0,0,0,275,400,0,0,0)
  ImageGadget(32,0,0,100,83,UseImage(32))
DisplaySprite(19,10,10)
DisplaySprite(19,95,10)
DisplaySprite(19,180,10)
DisplaySprite(19,10,95)
DisplaySprite(19,95,95)
DisplaySprite(19,180,95)
DisplaySprite(19,10,180)
DisplaySprite(19,95,180)
DisplaySprite(19,180,180)

DisableGadget(11,1)
DisableGadget(12,1)
DisableGadget(13,1)


If livello=1:Goto easy:EndIf
If livello=2:Goto hard:EndIf
;-livello easy + inizio

-load file binary

1:IncludeBinary "1.jpg"
faccia:IncludeBinary "faccia.bmp"
x:IncludeBinary "x.jpg"
0:IncludeBinary "0.jpg"
about:IncludeBinary "about.jpg"

this only a piece ...of code with code indent
Last edited by LESTROSO on Wed Feb 08, 2006 10:06 am, edited 1 time in total.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Have you heard of

Code: Select all

code tags? they
     preserve indent better
User avatar
LESTROSO
Enthusiast
Enthusiast
Posts: 124
Joined: Thu Nov 03, 2005 12:30 pm
Location: Italy
Contact:

Post by LESTROSO »

Sorry Trond, :(

but i don't understand, what do you mean code tags?? i saw the forum you told me, but i didn't see any purepasic arguments........
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Hi LESTROSO,

Trond just recommended to use code-tags around your code in order
to make it easier to read and remain the indentation. The forum you're
speaking of is part of his signature! ;)

Code-Tags:

[#code]
[#/code]

(without the #)

Just try it :)
Good programmers don't comment their code. It was hard to write, should be hard to read.
User avatar
LESTROSO
Enthusiast
Enthusiast
Posts: 124
Joined: Thu Nov 03, 2005 12:30 pm
Location: Italy
Contact:

Post by LESTROSO »

Thanks traumatic, now i've understood..... i've modified the my code with the tags code........ :wink:

Now, can anyone help me?? thanks a lot......
Post Reply