Page 2 of 2

PostPosted: Thu May 11, 2006 9:20 am
by Fuzzy
The use of 0000 is simply a formating trick; it causes four zeros to be shown by the actor. in the actual code, just use one.

to put a barrier that the player cannot see, create an actor, and instead of using "normal" use wireframe region. then you use a non collision actor for the graphic overlayed on top of that.

PostPosted: Thu May 11, 2006 9:35 am
by sali11
ok cool, ill try that out, what code do you think I should use for stopping the power going below 0

thanks again

PostPosted: Thu May 11, 2006 10:25 am
by DilloDude
On your keydown that decreases the number, put
Code: Select all
if (textNumber > 0)
{
    textNumber -= 1;
}

and to increase it
Code: Select all
if (textNumber < maxrange)
{
    textNumber +=1;
}

where maxrange is the highest velocity you want it to be.
Or you could add a draw actor:
Code: Select all
if (textNumber < 0)
{
    textNumber = 0;
}
if (textNumber > maxrange)
{
    textNumber = maxrange;
}


If instead of a number you want a bar that moves, first you need an animation for your bar, where the first frame represents zero, and the last frame represents maxrange. You can use any number of frames, but you won't want more than maxrange, and the higher the more accurate it will be. Add this to the actor that controls the initial velocity.
Now, using the 'variables' button in the script editor window, create a global real variable (eg vel). Change your keydown events to change vel rather than textNumber. In create actor, add a change animation direction function, and set it to STOPPED. In draw actor, write
Code: Select all
animpos = (vel / maxrange) * nframes;

this should make the animation reflect the velocity. Then, just set directional_velocity to vel.

PostPosted: Thu May 11, 2006 11:42 am
by sali11
Hi DilloDude thanks for the code, im gona try adding the first part of the code to controle the power speed,

the code:

if (textNumber > 0)
{
textNumber -= 1;
}

this checkes if the textNumber is less then 0 and if it is then the -=1 subtracts 1 from -1 keeping it at 0. correct? i thought it would be +1 to keep it at 0, or have i got the wrong end of the stick?

i thought that when you want to say 'less then' you use < , i gess you go by the right side of the simble.

for the code:

if (textNumber < maxrange)
{
textNumber +=1;
}

dont I have to set a maxrange first?
like:
maxrange = 50;

the code:

if (textNumber < 0)
{
textNumber = 0;
}

that looks like it keeps the textNumber at 0 if the texnumber is lower then 0 which is what im trying to do, Im I right in that?

the code:

if (textNumber > maxrange)
{
textNumber = maxrange;
}

this looks like it keeps the textNumber at the a set maxrange if it ends up greater then maxrange

sorry about nitpicking your code, i just want to understand it 100% before I apply it

thanks again for your help

PostPosted: Thu May 11, 2006 4:03 pm
by sali11
Hi, iv been looking over your code all day and i know how it works now lol :oops:

one question is still about the code

if (textNumber < maxrange)
{
textNumber +=1;
}

will i need to add this first to define the code

maxrange = 50;

PostPosted: Fri May 12, 2006 7:58 am
by DilloDude
Yes, either you can set at the beginning of the code:
Code: Select all
int maxrange = 50;

or just replace every occurence of maxrange with 50. If you set it as a variable it is easy to change to test it. Or you can set it depending on defferent circumstances. But in this case you'l probably want it to be constant, so you could say
Code: Select all
const int maxrange = 50;
and then you shouldn't be able to accidentally change it further on in the script.

PostPosted: Fri May 12, 2006 8:58 am
by sali11
ok cool, after thinking over it for ages it finally came to me :idea: to just do this :

if (textNumber < 40)
{
textNumber +=1;
}

and it worked fine.

when I tested it I found a different bug which was that if the space bar was hit when the speed is 0 the ball would still move back ever so slightly. so I applyed the if statment to correct that:

if (directional_velocity > 0)
{
directional_velocity = directional_velocity * 0.95;
}

so now the ball is behaving itself in regards to the power.

However, the ball is still getting stuck on the wall sometimes or passing through it. I did what ThreeFingerPete advised which was to make the wall thicker. But that did not seem to fix the problem. The wall ends up out of the screen view, do you think its because the safe margin is set at 20? i might play about with that setting when I get home.

If i have 30fps and i set the velocity to 40 how thick should the wall be to fix this problem?

thanks for all ur help in this, :) both of you

PostPosted: Fri May 12, 2006 3:54 pm
by Just4Fun
However, the ball is still getting stuck on the wall sometimes or passing through it.


This is probably WAY too simplistic, but I just had to ask it anyway:

Are you using 'wire frame' actors to serve as your 'walls'? I've never had any trouble with balls going through a 'wall' when I used a 'wire frame ' actor. :?:

PostPosted: Fri May 12, 2006 8:19 pm
by sali11
Hi Just4Fun,

I am not using a wire fram, actor. I am using a normal actor and have applyed collision events to it.

Im a noobe so im still learning. How do you apply the wire fram for your walls then?

PostPosted: Fri May 12, 2006 10:15 pm
by Just4Fun
sali11:

"The Wire Frame Actor can be used to create a barrier that repels game objects like balls. As an example, in a pinball game, the ball might bounce off of a wire frame barrier. The Wire Frame Region doesn't register mouse clicks."

You create a Wire Frame Actor just like you do a Normal actor. Just select the Wire Frame option from the dropdown box in the Create Actor Panel. "A Wire Frame Region Actor is shown within the Game Editor stage as a green rectangle. It can be moved or resized freely. The rectangle is invisible when the game is running in game mode."

A couple of demos that I would recommend looking at are Jazz-e-Bob's Mini Golf and my Tiny Pong demo. My demo uses Wire Frame Actors to set the boundries of the game stage. Jazz-e-Bob's demo might give you a few more ideas related to your golf game's ball movement. These demos are located in the demo section on this website.

Wire Frame Actors come in handy, but they may not be exactly what you are after in your game... HTHs

PostPosted: Sat May 13, 2006 10:23 am
by sali11
ok, cool.
Ill have a look at those demos again and try to apply it to my walls, thanks for your help :)

PostPosted: Sat May 13, 2006 1:25 pm
by sali11
Hi Just4Fun. iv been looking at your Tiny Pong demo and used the same method as you for my game.

I found that it still reacts the same way, some times it sticks as soon as it touches the wire frame, regardless of the speed its going. if i waite a while and then hit the ball it bounces fine. When the ball is going very fast it bounces ok, when its slow it sticks.

Iv also noticed that in the Tiny Pong demo, the ball passes through the side walls as well if you hit it too hard on the side, dont know if you have ever noticed that.

I tested the collision of the Mini golf game and that works perfectly. I had a look at how it was done, and found scripting for it on the ball collision event:

if ( directional_velocity > 1 )
PlaySound2("data/hitBarrier.wav", 1.000000, 1, 0.000000);

PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.0, 1.0, 1.0, 1.0);

sorting this problem out seem a bit more complicated then it looks.

does any one know how the coding for the mini golf collisions works, and if so, would it be possible for a noobe tutorial on how to duplicate it?

any help would be great, thanks :)

PostPosted: Mon May 15, 2006 9:31 pm
by Just4Fun
Sali11:
I've been out of town and just now noticed your question.

I am sorry about the Tiny Pong demo. You are right, I've never experienced the ball passing through the walls. I had hoped that using the 'wire frame' actor would solve that issue for you. I wish that I had a good answer for your troubles, but I'm just not sure now and I don't want to give you wrong information.

As far as Jazz-e-Bob's golf demo goes, I am pretty sure that you can trust the coding there. Jazz is someone who is very good at programming. Unfortunately, he isn't currently around the forum. I do believe that Trajecto might be able to jump in and help with the problematic balls. He did the pong tutorial that is here in the forum. He is also a professional class programmer. ThreeFingersPete is also very good at programming in 'C'. My guess is that someone here will be able to help you find the solution. I'm just sorry that I led you a little astray with my 'wire frame' actor solution...

PostPosted: Mon May 15, 2006 10:45 pm
by sali11
thats ok, no need to say sorry, you were just trying to help after all. and I appricate what you and every one els has done to help me in this so far.

As for the problem, i gess I will have to wait and see if any one els has any good ideas around this problem. so if there is any one out there who might have a fix for this, and can explain how to apply it in nooby terms, im all ears.