Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / sound don't work

Author
Message
timsky
18
Years of Service
User Offline
Joined: 16th Mar 2006
Location:
Posted: 27th Mar 2006 17:59
won\'t execute try\'s to.what iam i doing wrong
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 27th Mar 2006 18:53
start by using forum code tags, the Source button thing sucks



FREE Automatic file updates for your distributed Games and Apps - see Program Announcements Forum - DBP Demo
timsky
18
Years of Service
User Offline
Joined: 16th Mar 2006
Location:
Posted: 28th Mar 2006 18:44
REM Project: tim6
REM Created: 3/22/2006 11:10:01 AM
REM
REM ***** Main Source File *****
sync on
sync rate 25
hide mouse
autocam off
position camera 0,5,0
color backdrop rgb(100,100,155)
fog on
fog color rgb(100,100,155)
fog distance 2000

`grass
for x=1 to 10
for y=1 to 10
ink rgb(rnd(100),rnd(155)+100,0),0
dot x,y
next y
next x
get image 1000,1,1,10,10
make object plain 1000,2000,2000
xrotate object 1000,-90
texture object 1000,1000
scale object texture 1000,10,10
set object texture 1000,2,0

`particle properties
numberofparticles=10000
dim x#(numberofparticles)
dim y#(numberofparticles)
dim xspeed#(numberofparticles)
dim yspeed#(numberofparticles)
dim brightness(numberofparticles)
dim a#(numberofparticles)
dim e#(numberofparticles) `phase angle
for particle=1 to numberofparticles
x#(particle)=rnd(screen width())
y#(particle)=rnd(screen height())
xspeed#(particle)=(rnd(3000)/1000.0)
e#(particle)=rnd(360)
brightness(particle)=rnd(100)+100
a#(particle)=gaussian(2*screen width())-screen width() `amplitude
gravitya#=.01
gravityb#=1.0
omega#=0.0006 `primary angular velocity
phi#=2.0 `secondary angular velocity
next particle

do
inc counter
if counter>1000 then counter=0
if counter=100 or counter=110 or counter=400
color backdrop rgb(255,255,255)
else
color backdrop rgb(100,100,155)
endif

gosub particles
control camera using arrowkeys 0,1,1
if counter/2.0=int(counter/2.0) then sync
loop

particles:

text 0,0,str$(screen fps())
lock pixels

`tornado particles
for particle=1 to numberofparticles step 2
inc y#(particle),gravityb#
if y#(particle)>0 and y#(particle)<screen height() and x#(particle)>0 and x#(particle)<screen width() then set_locked_pixel(x#(particle),y#(particle),rgb(brightness(particle),brightness(particle),200))
x#(particle)=(500/y#(particle)^1.5)*a#(particle)*sin(theta#+e#(particle))+screen width()/2+(20*sin(y#(particle)+psi#))
theta#=wrapvalue(theta#)+omega#
if y#(particle)>=screen height()/1.5 then dec y#(particle),screen height()
next particle
psi#=wrapvalue(psi#)+phi#

`background particles
for particle=2 to numberofparticles step 2
inc y#(particle),gravityb#
if y#(particle)>screen height()-1 then y#(particle)=1
if y#(particle)>0 and y#(particle)<screen height() and x#(particle)>0 and x#(particle)<screen width() then set_locked_pixel(x#(particle),y#(particle),rgb(brightness(particle),brightness(particle),200))
inc x#(particle),xspeed#(particle)
if x#(particle)>screen width()-1 then x#(particle)=1
next particle
unlock pixels
return

`Function borrowed from Coding Fodder's Rain code
function set_locked_pixel(x,y,color_value)
start=get pixels pointer()
repeat_number=get pixels pitch()
bits_per_pixel=bitmap depth(num)/8
pointer=start+y*repeat_number+x*bits_per_pixel
*pointer=color_value
endfunction



function gaussian(range#)

r=0
for a = 1 to range#/10
inc r, rnd(range#)
next a

r=int(10*r/range#)

endFunction r

rem load sound
load sound "sound\timetodie.wav",1
if soundnumber=1
play sound 1
endif
end
won't play sound can ya help
Doldren
18
Years of Service
User Offline
Joined: 18th Jan 2006
Location:
Posted: 1st Apr 2006 19:35 Edited at: 1st Apr 2006 19:47
problems gonna be either in the condition that sets the soundnumber variable or the file name/location

you'll need a bit of code that does something like
*******************************
DIM SoundNumber as integer

Do
If SpaceKey() = 1
SoundNumber = 1
Endif
Loop
*******************************
Just using spacekey pressed as an example of a user action

(soz if this isn't of help still a bit of a n00b myself)

* bump

or u could always put the sound inside the condition after loading it at the top
********************
Load Sound "sounds\sound.wav", 1

Do

If SpaceKey() = 1
Play Sound 1
EndIf

Loop

Login to post a reply

Server time is: 2024-11-27 22:53:35
Your offset time is: 2024-11-27 22:53:35