PureBasic Game Tutorials???

Advanced game related topics
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

Looking good Hypervox.. keep it up! :D

Lars

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

Do you really need to create a gadget list if you have no gadgets?
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
hypervox
User
User
Posts: 48
Joined: Mon Apr 28, 2003 10:02 am
Location: UK
Contact:

Post by hypervox »

probably not! That's the Visual Designer for you.....

I think I'll change that to read "only if you're going to use a gadget!" :oops:

Thanks Tinman :)
PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 :D
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000 :)
Registered Purebasic User :D

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Nice

Post by LJ »

Nice work.
Searhin
User
User
Posts: 41
Joined: Mon May 26, 2003 10:53 am
Location: Germany

Post by Searhin »

Thanx a lot hypervox! Great work (and please do continue :D )
hypervox
User
User
Posts: 48
Joined: Mon Apr 28, 2003 10:02 am
Location: UK
Contact:

Post by hypervox »

Next stage of the game creation tutorial has been posted - Simple Sprites
PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 :D
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000 :)
Registered Purebasic User :D

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Screen Save...

Post by LJ »

The tutorial says:" ; save screenshot
If KeyboardPushed(#PB_Key_F1)
GrabSprite(#snapshot,0,0,#SCREEN_WIDTH,#SCREEN_HEIGHT)
SaveSprite(#snapshot,"screenshot.bmp")
EndIf"

However, in the actual source code available for download, there is no save screenshot code. I added the code manually myself, and found it didn't work properly, only grabbed a blank black screen.

Nice work. I'm enjoying your tutorial very much.

Lj
hypervox
User
User
Posts: 48
Joined: Mon Apr 28, 2003 10:02 am
Location: UK
Contact:

Post by hypervox »

Sorry LJ - the correct source has been uploaded.

The snapshot code has to go just after the first initial keycheck, like so....

;///////////////////////////////////////////////////
;- Input
;///////////////////////////////////////////////////
;check keyboard For input
;if escape pressed, leave program,
;if + or - pressed, change speed of starfield
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
done = 1
EndIf

; save screenshot
If KeyboardPushed(#PB_Key_F1)
GrabSprite(#snapshot,0,0,#SCREEN_WIDTH,#SCREEN_HEIGHT)
SaveSprite(#snapshot,"screenshot.bmp")
EndIf
PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 :D
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000 :)
Registered Purebasic User :D

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

OK

Post by LJ »

OK, excellent! Everything is working great!
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Hypervox

Post by LJ »

Hypervox, how is your next tutorial coming along? I've really enjoyed the ones you've created so far.
hypervox
User
User
Posts: 48
Joined: Mon Apr 28, 2003 10:02 am
Location: UK
Contact:

Post by hypervox »

next one should hopefully be ready in a couple of days, and will concern animated sprites.

(p.s. sorry for the delay everyone, other commitments etc... :wink: )
PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 :D
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000 :)
Registered Purebasic User :D

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
hypervox
User
User
Posts: 48
Joined: Mon Apr 28, 2003 10:02 am
Location: UK
Contact:

Post by hypervox »

next tutorial available - animated sprites & sounds!

Rgrds everyone

Hypervox :D
PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 :D
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000 :)
Registered Purebasic User :D

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Nice...

Post by LJ »

Your latest tutorial is fantastic.

The sounds are functioning, hmmm, how to describe,... in a inconsistent way. Notice that when the program is first run, the background sound voidhum.wav is of a good volume. As the program is running, if you push the space bar which plays phaser.wav it sounds good. But sometimes when you push the spacebar, the volume of the first sound, voidhum.wav, decreases and is hardly audible. The phaser.wav volume decreases also. Now push the space bar a few more times, and if you're lucky, the volume suddenly increases again back to its original volume and everything sounds great. As you push the space bar at different times and different speeds, the sound makes almost a crackle sound, but not quite and again, the volume decreases. Sometimes you are stuck at a decreased volume for both the phaser.wav and the voidhum.wav for a considerable amount of time, but eventually, if you keep pushing the spacebar, you can get the volume to increase again.

I notice that with the PlaySound command, there doesn't appear to be different channel to load the sound as in the Blitz3D language. Could the problem be that because there are not different channels, by repeating the sound before its completely finished cause the decrease in volume?
The logic is that EVERYTIME the program is first executed, the volume is always correct. But when the phaser.wav sound is introduced on the same channel and stopped and started at different times, the volume alternates between a very low and normal state.

And if everyone gets the problem I described above, is this a bug to report to Fred or is it corrected by allowing the phaser sound to fully play and terminate before playing again?
hypervox
User
User
Posts: 48
Joined: Mon Apr 28, 2003 10:02 am
Location: UK
Contact:

Post by hypervox »

What's happenning is that the Playsound command for the phaser sound is being fired every time the space key is pressed. If you hold down the space key, the sound plays repeatedly. Depending on how fast your keyboard repeat is, this can give the effect of the sound being "chopped off", or even silence!

I don't think the volume itself is changing, but this repeat effect could manifest itself this way.

I think I'll post a query on this, because I'm not happy with this situation. The Windows PlaySound API call can stop a sound if it's already playing, but I think it can also not play a sound if it's already in progress. Let's see what Fred says...
PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 :D
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000 :)
Registered Purebasic User :D

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

OK

Post by LJ »

Ok. I've tried modifying your code to fix, but no luck. I tried just changing the frequency of the hum noise, I tried detecting if the sound was still playing using the initsound command, no luck.

The only thing that would possibly work is to stop game execusion with a delay command until the sound finished, but that would be terrible as far as game playability goes.

What we need is a way to detect if the phaser sound is still playing, and if it is, don't play it again. The problem with using the initsound command to do this is that the other sound, the hum sound is playing in the background and so the initsound command always returns that the sound is busy.
Post Reply