Need some help in my game. (can close this now)

Advanced game related topics
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Need some help in my game. (can close this now)

Post by Joakim Christiansen »

http://www.myhome.no/joakims_gamemaker_page/Game.zip
When i load a background the player sprite gets white, just run it and you will see.
Can someone help me with this? (i'm a noob)

Edit:
Is it also best if i free the sprites and sounds (resources) when i end the game?
Last edited by Joakim Christiansen on Tue Jan 11, 2005 8:44 pm, edited 3 times in total.
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Where have you defined the values for
spr_player
spr_background
????

And just in case you didn't know, variables inside a procedure are not global unless you make them. ;)
Image Image
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

And just in case you didn't know, variables inside a procedure are not global unless you make them. ;)
I knew that.
Where have you defined the values for
spr_player
spr_background
????
They are defined in the InitResources() procedure i think...
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

So you see your error now? :)
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

Paul wrote:So you see your error now? :)
CreateSprite3D(spr_player, spr_player)
I must make that global?

Code: Select all

  Global spr_player3d
  ;Sounds
  LoadSound(snd_shoot, "data\sounds\shoot.wav")
  ;Sprites
  LoadSprite(spr_player, "data\sprites\player.bmp", #PB_Sprite_Texture)
  CreateSprite3D(spr_player3d, spr_player)
  TransparentSpriteColor(spr_player, 255, 255, 255)
  LoadSprite(spr_background, "data\images\background.bmp")
That did'nt work, hmm...
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Here is your updated file...
http://www.reelmedia.org/test/gm.zip

You have not defined spr_player or spr_background so the are both 0. Sprites must have unique numbers, they cannot share. Personally I would make then constants since they never change anyway and then you don't have to worry about making them global. (see update file)

Also, for the least amount of problems, use pure black as your transparent color. TransparentSpriteColor() is not reliable.
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

Thank you very much! :D
I now undestand things a little bether :D
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Is it also best if i free the sprites and sounds (resources) when i end the game?
You don't have to, PB does this for you once the program is ended.
--Kale

Image
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

Thanks :D
matthew180
User
User
Posts: 64
Joined: Mon Jun 30, 2003 5:36 pm
Location: Michigan
Contact:

Post by matthew180 »

Paul wrote:Also, for the least amount of problems, use pure black as your transparent color. TransparentSpriteColor() is not reliable.
Can you please expand on this? I'm working on a project with a lot of graphics and I've been using hot-pink (255,0,255) as transparent. Am I going to have "pink background" problems on some systems?

Matthew
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

From my personal experiences... YES

The only color I have never had problems with is the default transparency (0,0,0) pure black.

I prefer using pure black anyways... I make my graphics on a layer in Photoshop. When done, I raise the output level of that layer by 10, set the background layer as 0,0,0 and then save. Works great! ;)
Post Reply