Upload well and truly uploaded.
Comments?
Comments?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu#define SOUND_SOURCE_COUNT 3
SoundSource soundSources[SOUND_SOURCE_COUNT];
void StopSoundSources()
{
for(int i=0; i<SOUND_SOURCE_COUNT; i++)
soundSources[i].Stop();
}
import void StopSoundSources();
function late_repeatedly_execute_always()
{
for(int i=0; i<SOUND_SOURCE_COUNT; i++)
soundSources[i].UpdateVolume(player.x, player.y);
}
void SoundSource::UpdateVolume(int x, int y)
{
if(this.channel != null)
{
int dx = this.x - x;
int dy = this.y - y;
int d_squared = dx*dx + dy*dy;
if(d_squared >= radius*radius) <===== Undefined symbol 'radius'
this.channel.Volume = minVolume;
else
this.channel.Volume = FloatToInt(100.0 - (Maths.Sqrt(IntToFloat(d_squared))/IntToFloat(radius)) * (100.0 - IntToFloat(minVolume)));
}
}
bool SoundSource::Init(AudioClip* clip, AudioPriority pri, int x, int y, int radius, int minVolume)
{
if(this.channel != null)
this.channel.Stop();
this.x = x;
thix.y = y;
this.radius = radius;
this.minVolume = minVolume;
this.channel = clip.Play(pri, eRepeat);
return this.channel != null;
}
void SoundSource::Stop()
{
if(this.channel != null)
this.channel.Stop();
this.channel = null;
}
void StopSoundSources()
{
for(int i=0; i<SOUND_SOURCE_COUNT; i++)
soundSources[i].Stop();
}
struct SoundSource
{
AudioChannel* channel;
int x;
int y;
int radius;
int minVolume;
import bool Init(AudioClip* clip, AudioPriority pri, int x, int y, int radius, int minVolume);
import void UpdateVolume(int x, int y);
import void Stop();
};
#define SOUND_SOURCE_COUNT 3
SoundSource soundSources[SOUND_SOURCE_COUNT];
import function StopSoundSources();
function room_Load()
{
soundSources[0].Init(aFlys2, eAudioPriorityNormal, 415, 610, 50, 2);
soundSources[1].Init(aMeatMarket_tinnyradio, eAudioPriorityNormal, 1150, 365, 80, 40);
}
function late_repeatedly_execute_always()
{
for(int i=0; i<SOUND_SOURCE_COUNT; i++)
soundSources[i].UpdateVolume(player.x, player.y);
}
function soundPlayLocation (int x, int y, float r, AudioClip* soundSample, int residual)
{
float d=0.0;
int p=0;
int sp=0;
if (soundPlayer1==null) {
sp=1;
soundPlayer1=soundSample.Play(eAudioPriorityNormal, eRepeat);
} else {
if (soundPlayer2==null) {
sp=2;
soundPlayer2=soundSample.Play(eAudioPriorityNormal, eRepeat);
} else {
if (soundPlayer3==null) {
sp=3;
soundPlayer3=soundSample.Play(eAudioPriorityNormal, eRepeat);
} else {
Display("more than 3 sound samples.");
return -1;
}
}
}
float dx = IntToFloat(abs(player.x - x));
float dy = IntToFloat(abs(player.y - y));
d=Maths.Sqrt((dx * dx) + (dy * dy));
if (d>r) {
switch (sp) {
case 1: soundPlayer1.Volume=residual;
case 2: soundPlayer2.Volume=residual;
case 3: soundPlayer3.Volume=residual;
}
} else {
p=FloatToInt( 100.0-((d/r)*100.0) );
if (p<residual) p=residual;
switch(sp) {
case 1: soundPlayer1.Volume = p;
case 2: soundPlayer2.Volume = p;
case 3: soundPlayer3.Volume = p;
}
}
}
soundPlayLocation(415, 610, 50.0, aFlys2, 10);
switch (sp) {
case 1: soundPlayer1.Volume=residual; <--THIS LINE - 'null pointer referenced'
case 2: soundPlayer2.Volume=residual;
case 3: soundPlayer3.Volume=residual;
}
if (soundPlayer1==null) {
sp=1;
//if (soundPlayer1.PlayingClip!=soundSample)
soundPlayer1=soundSample.Play(eAudioPriorityNormal, eRepeat);
...
function dialog_options_get_dimensions(DialogOptionsRenderingInfo* info)
{
ConversationIsOn=true;
dialog_left=11;
info.X = 0;
info.Y = 672;
info.Width = 1366;
info.Height = 96;
MyDynamicSpriteForTheFakeGUI = DynamicSprite.Create(info.Width, info.Height, true);
DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
ds.DrawImage(0, 0, 2639);
ds.Release();
gFakeDialogOptions.BackgroundGraphic = MyDynamicSpriteForTheFakeGUI.Graphic;
gFakeDialogOptions.Visible = true;
}
//----------------------------------------------------------------------------------------------------------------------
// Draw Dialog Options
//----------------------------------------------------------------------------------------------------------------------
function DrawDialogOptions(DrawingSurface* ds, DialogOptionsRenderingInfo* info)
{
int i = 1, ypos = 0, xpos = dialog_left;
while (i <= info.DialogToRender.OptionCount)
{
if (info.DialogToRender.GetOptionState(i) == eOptionOn)
{
gFakeDialogOptions.BackgroundGraphic = MyDynamicSpriteForTheFakeGUI.Graphic;
gFakeDialogOptions.Visible = true;
String str = info.DialogToRender.GetOptionText(i); //get glyph number from option text
int cur_img = str.AsInt; //current image is that number
ds.DrawImage(xpos, ypos, cur_img); //draw this glyph
xpos = xpos + 96; //xpos+=width of glyph
}
i++;
}
}
//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Render
//----------------------------------------------------------------------------------------------------------------------
function dialog_options_render(DialogOptionsRenderingInfo* info)
{
DrawDialogOptions(info.Surface, info);
}
//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Repeat Exec
//----------------------------------------------------------------------------------------------------------------------
function dialog_options_repexec(DialogOptionsRenderingInfo* info)
{
gFakeDialogOptions.BackgroundGraphic = MyDynamicSpriteForTheFakeGUI.Graphic;
gFakeDialogOptions.Visible = true;
int i = 1, xpos = dialog_left;
while (i <= info.DialogToRender.OptionCount)
{
if (info.DialogToRender.GetOptionState(i) == eOptionOn)
{
if ( mouse.y >= info.Y
&& mouse.x >= xpos
&& mouse.x <= xpos+96)
{
info.ActiveOptionID = i;
DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
DrawDialogOptions(ds, info);
ds.Release();
return;
}
xpos += 96;
}
i++;
}
}
//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Mouse Click
//----------------------------------------------------------------------------------------------------------------------
function dialog_options_mouse_click(DialogOptionsRenderingInfo* info, MouseButton button)
{
if (info.ActiveOptionID > 0)
{
DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
DrawDialogOptions(ds, info);
ds.Release();
gFakeDialogOptions.BackgroundGraphic = MyDynamicSpriteForTheFakeGUI.Graphic;
gFakeDialogOptions.Visible = true;
info.RunActiveOption();
}
}
function dialog_options_get_dimensions(DialogOptionsRenderingInfo* info)
{
ConversationIsOn=true;
dialog_left=11;
info.X = 0;
info.Y = 672;
info.Width = 1366;
info.Height = 96;
MyDynamicSpriteForTheFakeGUI = DynamicSprite.Create(info.Width, info.Height, true);
DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
ds.DrawImage(0, 672, 2639);
ds.Release();
}
//----------------------------------------------------------------------------------------------------------------------
// Draw Dialog Options
//----------------------------------------------------------------------------------------------------------------------
function DrawDialogOptions(DrawingSurface* ds, DialogOptionsRenderingInfo* info)
{
int i = 1, ypos = 0, xpos = dialog_left;
while (i <= info.DialogToRender.OptionCount)
{
if (info.DialogToRender.GetOptionState(i) == eOptionOn)
{
String str = info.DialogToRender.GetOptionText(i); //get glyph number from option text
int cur_img = str.AsInt; //current image is that number
ds.DrawImage(xpos, ypos, cur_img); //draw this glyph
xpos = xpos + 96; //xpos+=width of glyph
}
i++;
}
}
//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Render
//----------------------------------------------------------------------------------------------------------------------
function dialog_options_render(DialogOptionsRenderingInfo* info)
{
DrawDialogOptions(info.Surface, info);
}
//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Repeat Exec
//----------------------------------------------------------------------------------------------------------------------
function dialog_options_repexec(DialogOptionsRenderingInfo* info)
{
int i = 1, xpos = dialog_left;
while (i <= info.DialogToRender.OptionCount)
{
if (info.DialogToRender.GetOptionState(i) == eOptionOn)
{
if ( mouse.y >= info.Y
&& mouse.x >= xpos
&& mouse.x <= xpos+96)
{
info.ActiveOptionID = i;
//transplanted in from dialogue_options_mouse_click() to get rid of background/old buttons in real time
DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
DrawDialogOptions(ds, info);
ds.Release();
return;
}
xpos += 96;
}
i++;
}
gFakeDialogOptions.Visible = false;
}
//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Mouse Click
//----------------------------------------------------------------------------------------------------------------------
function dialog_options_mouse_click(DialogOptionsRenderingInfo* info, MouseButton button)
{
if (info.ActiveOptionID > 0)
{
DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
DrawDialogOptions(ds, info);
ds.Release();
gFakeDialogOptions.BackgroundGraphic = MyDynamicSpriteForTheFakeGUI.Graphic;
gFakeDialogOptions.Visible = true;
info.RunActiveOption();
}
}
function dialog_options_get_dimensions(DialogOptionsRenderingInfo* info)
{
ConversationIsOn=true;
// Create a 1366x96 dialog options area at (0,704)
dialog_left=11;
info.X = 0;
info.Y = 672;
info.Width = 1366;
info.Height = 96;
}
//----------------------------------------------------------------------------------------------------------------------
// Draw Dialog Options
//----------------------------------------------------------------------------------------------------------------------
function DrawDialogOptions(DrawingSurface* ds, DialogOptionsRenderingInfo* info)
{
ds.DrawImage(0, 672, 2639);
int i = 1, ypos = 0, xpos = dialog_left;
while (i <= info.DialogToRender.OptionCount)
{
if (info.DialogToRender.GetOptionState(i) == eOptionOn)
{
String str = info.DialogToRender.GetOptionText(i); //get glyph number from option text
int cur_img = str.AsInt; //current image is that number
ds.DrawImage(xpos, ypos, cur_img); //draw this glyph
xpos = xpos + 96; //xpos+=width of glyph
}
i++;
}
}
//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Render
//----------------------------------------------------------------------------------------------------------------------
function dialog_options_render(DialogOptionsRenderingInfo* info)
{
DrawDialogOptions(info.Surface, info);
}
//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Repeat Exec
//----------------------------------------------------------------------------------------------------------------------
function dialog_options_repexec(DialogOptionsRenderingInfo* info)
{
MyDynamicSpriteForTheFakeGUI = DynamicSprite.Create(info.Width, info.Height, true);
DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
ds.DrawImage(0, 672, 2639);
int i = 1, xpos = dialog_left;
while (i <= info.DialogToRender.OptionCount)
{
if (info.DialogToRender.GetOptionState(i) == eOptionOn)
{
if ( mouse.y >= info.Y
&& mouse.x >= xpos
&& mouse.x <= xpos+96)
{
info.ActiveOptionID = i;
//transplanted in from dialogue_options_mouse_click() to get rid of background/old buttons in real time
DrawDialogOptions(ds, info);
ds.Release();
return;
}
xpos += 96;
}
i++;
}
gFakeDialogOptions.Visible = false;
}
//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Mouse Click
//----------------------------------------------------------------------------------------------------------------------
function dialog_options_mouse_click(DialogOptionsRenderingInfo* info, MouseButton button)
{
if (info.ActiveOptionID > 0)
{
MyDynamicSpriteForTheFakeGUI = DynamicSprite.Create(info.Width, info.Height, true);
DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
ds.DrawImage(0, 672, 2639);
DrawDialogOptions(ds, info);
ds.Release();
gFakeDialogOptions.BackgroundGraphic = MyDynamicSpriteForTheFakeGUI.Graphic;
gFakeDialogOptions.Visible = true;
info.RunActiveOption();
}
}
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.062 seconds with 14 queries.