Menu

Show posts

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

Messages - smartastreacle

#21
Hi, I can add code if required but I think this is a very simple question that I am momentarily stumped on. I have two animated objects. One is a non player character character, let's say a clown,  the other is a radar scope. The clown is animated in one location  dancing on the spot, I can move the radar scope (a 50x50 square) around the screen using setPosition. Trouble is if I place the radar scope on the clown it appears underneath when it should be on top. Is this a zorder thing, or a enoblock? In a nutshell, if I set the radar scope at the location of the clown how can I make sure it appears on top? Hopefully this is a nice easy question for someone enjoying a croissant and a nice cup of coffee.  ;)
#22
Cassiebsg: Done. A little knowledge goes a long way.  (laugh)

Crimson Wizard: Noted. I might actually use some speech now.  :)

So, this is solved. To clarify, for those struggling at the noob end like me, the problem was I did not know about sound types so the dig sound and the explosion sound were competing on the same channel.
Type in the aveggun property box was Ambient Sound, type in the dig property box was Ambient Sound, in Explore Project/Audio/Types Ambient Sound was given a MaxChannels of 1. With gun and dig now defined as Sound and Sound given MaxChannels of 0 the rest of the available channels could handle the two sfx with no problem. Oh, and I could now allocate the sound to the correct frame in the view. I knew it would be easy. (I think that's right, if it's wrong I'll crawl back in my hole).

#23
OK, I didn't know about the sound types. I stuck dig in ambient and cannon in sound (was maxchannels = 0 changed to 3 in the tree) and shortened the cannon clip. Now it all works a treat and hopefully still have room for another cannon and some mechanical sounds. If I have more time I will explain more clearly (I have to go out) but I hope I am using sound types right now.
I saw the tip from Crimson Wizard:

'Also, increase number of channels for music [or ambient or sound]. In your project tree select "Audio"->"Types"->"Music" and change MaxChannels property.'


'New audio system is explained in the manual which comes with AGS Editor.
Specifically:
- "Other features"->"Music and sound";
- "Scripting" -> "AudioChannel functions and properties";
- "Scripting" -> "AudioClip functions and properties";'
#24
Oh you are right! I'd forgotten about that. I'll give it a go and move things around.

Thank you.

Question about the channels still open though.  (nod)

Update. Syncs up fine but cancelling still the issue. Cannon sound is 6 seconds so never hear the digging.
#25
Sorry I posted this before I had finished writing it, I hope there's enough there for you.  8-0

I edited.
#26
Hi, and audioclip and audiochannel question! (boom (sound effect))  :)

I have a cannon firing and someone digging. Both are animated and start on fade in of the room.
I have the sounds in the function room_RepExec() part of the room code. The digging has 7 frames, every frame 0 I have a digging sound, a shovel. The cannon has 16 frames and fires every frame 14. The animations run at different speeds.

Code: ags
function room_AfterFadeIn()
{
  object[0].SetView(11);     // This is the digger
    object[0].Animate(0, 4, eRepeat, eNoBlock);
  object[1].SetView(12);    // This is the cannon
    object[1].Animate(0, 8, eRepeat, eNoBlock);
}

function room_RepExec()
{      
  if (object[0].Frame == 0){
     ashovel.Play();    
  }
  if (object[1].Frame == 14){
     aveggun2.Play();
  }


Basically the issue is quite simple and I know it probably has an easy solution but I just haven't found it - the digging sound blocks out the cannon boom. My understanding is that both sounds are probably playing on the same audio channel, so, my question is - can I assign a sound to a particular audiochannel like:

Audiochannel 1 assign dig
Audiochannel 2 assign cannon?

or from something I have seen:

AudioChannel *dig;
AudioChannel *cannon;


// and later

  if (object[0].Frame == 0){
    dig = ashovel.Play();   
  }
  if (object[1].Frame == 14){
    cannon = aveggun2.Play();
}


I tried this and it didn't work. Do I have the theory right? Any help more than gratefully received.  :)
#27
Got it, thank you. I'm a noob. I'll get there.  :)
#28
Ah, thanks, Khris. I had a hunch that might be the case. The variable works way better. I had to give it a value of 4 though to kick it off. Should it have worked without that?

Code: ags

function room_RepExec()
{
  int prevFrame;
  prevFrame = 4;
  int HitChance;
  HitChance = Random(2);

  if(oNpcn.Frame == 5 && prevFrame == 4){
  if(HitChance == 2)
  gcarhealth.Width -= 10;
  prevFrame = oNpc.Frame;
  
  if(gcarhealth.Width < 15)
    cProf.ChangeRoom(18);
  
  else if(street_number == product)
    streetNo();
  }    
}
#29
I think I got stuck in a function in global script which took away control of the mouse. If I see it again I will demonstrate. Thanks for the tip on the code. My way was a bit scrappy huh?  (laugh)
#30
Thank you so much for this. I will try it. As a work around fudge, as the delay between frames is 5 as you pointed out, I stuck a wait of 5 at the end and it all synced up. Can't tell if that interferes with the mouse at the moment. I got to this:

function room_RepExec()
{
  int HitChance;
  HitChance = Random(2);
  if(oNpc.Frame == 5)
  if(HitChance == 2){
  gcarhealth.Width -= 10;
  Wait(5);
  if(gcarhealth.Width < 15)
    cme.ChangeRoom(18);
  }

A bit like fighter planes syncing their machine gune to fire between the blades. Not too sophisticated. I wanted, as you suggest, to use a variable. I was thinking of a boolean. I will try yours. Ideally I will change the hit chance to coincide with a random sound, clunk = miss, bash - hit and get the random points deduction from that.
Sometimes the mouse pointer appears outside the screen but not on it. What causes that?

I like this place. Thank you.   (nod)
#31
Thank you newwaveburritos (they sound tasty)

I will definitely go down this road. The more chaos the better  :-D

And thank you for the confirmation Cassiebsg.

Still losing all health in one cycle though. If I fix it I will let you know how.

The treacle  :P

#32
Hey Cassiebsg

Many thanks for the welcome -  :-D - and the suggestions. I am trying them out in-between sessions of watching sport.

Yes it's an object animation. Let's say the animation is an npc tank, let's call it oNpc. If the player destroys oNpc before being destroyed him/her self, they can move on, otherwise they get knocked back two rooms for repairs. oNpc has 7 frames. On frame 5 it fires. The shot hits or misses. If it hits the player loses 10 on the health bar, if it misses player loses nothing and so on. Health bar starts at 110. I tried (oNpc.Loop==5) but does this give the frame number or the loop? I changed it for (oNpc.frame==5) and that did give the frame so I could knock the health off at frame 5. Trouble is it does not stop. As so as we reach frame 5 it keeps taking off ten until we are down to negative health which causes an error as the health is tied to a gui width which can't be negative. I can put a condition in to stop at 10 and avoid that error. So, the question is: how do I sync 10 points off each cycle instead of losing all health at frame 5 in cycle 1?

I have so far:

function room_AfterFadeIn()
{
    object[0].SetView(9);
    object[0].Animate(0, 25, eRepeat, eNoBlock);   
}   

function room_RepExec()

  if(oNpc.Frame == 5)
  gcarhealth.Width = gcarhealth.Width - 10;   
}

I have delay at 25 so I can watch what happens. So how to sync room_RepExec() cycles to the object animation cycles and delete 10 each time we go round.
I know this is noob stuff but I am tearing my hair out.
  :~(
#33
Hi,

I am brand new to this so please be understanding.  :)

I have a room with an animation of 7 frames with 5 second delay on erepeat, enoblock. The animation works fine. I also have a health bar. Initially, I would like every time frame 5 comes round for 10 points to be knocked off the health bar so that decreases say from 150 down to 10 at which point the player gets knocked back to a previous room. I have read the manual and looked through the forums, I still don't know how best to achieve this. I have tried so many different things that I am shy at putting code up because there are so many versions of it. I am sure this is easy to achieve. Any ideas would be very much appreciated.
Once I can do the basics I would like for the 10 points to be knocked off randomly so at each cycle it's hit or miss if the reduction happens. In fact I would ideally like for successful random hits to happen in any of three frames - say 1, 3 and 6 of frames 0 through 7 occur. I would also have random hit sounds.
While this happens the player has to achieve something to stop the attack and win. This I can do.

Many thanks. This is my first post. Hi!  8-)


SMF spam blocked by CleanTalk