Guys please help me with this problem

Talk about making games.

Guys please help me with this problem

Postby raminjoon » Fri Aug 12, 2011 5:58 am

Okay I have 10 apples for i.e. after I use one I want the text that shows on screen that I got 10 apples to decrease and stop at zero. how?
raminjoon
 
Posts: 40
Joined: Tue Jul 05, 2011 5:34 am
Location: Denver, Co.
Score: 3 Give a positive score

Re: Guys please help me with this problem

Postby skydereign » Fri Aug 12, 2011 6:07 am

You've asked this question before, and the answer doesn't seem to have changed. If there are 10 apples and each time you collect one, you delete it, then you can use ActorCount.
apple_display -> Draw Actor -> Script Editor
Code: Select all
textNumber=ActorCount("apple");


If there isn't a one-to-one match for actors to the number of apples for some reason, use a variable (apple_count). Each time you get an apple, decrease it.
apple_display -> Draw Actor -> Script Editor
Code: Select all
textNumber=apple_count;


If this for some reason isn't what you wanted or you still don't understand, explain why. Please don't make several topics about the same question.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Guys please help me with this problem

Postby raminjoon » Fri Aug 12, 2011 2:52 pm

thanks for your reply and yes i did ask this Q before but for some reason it didnt work out but my main problem actually is that when it hits 0 it starts counting negative numbers which I dont need like it goes -1, -2, -3 and so on. how would I solve that problem.
raminjoon
 
Posts: 40
Joined: Tue Jul 05, 2011 5:34 am
Location: Denver, Co.
Score: 3 Give a positive score

Re: Guys please help me with this problem

Postby foleyjo » Fri Aug 12, 2011 5:32 pm

An Actor count shouldn't generate a negative number. There can never be less than 0 actors.
So I assume you are doing it using the apple_count method

Code: Select all
if (apple_count>=0)
  textNumber=apple_count;
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score

Re: Guys please help me with this problem

Postby skydereign » Fri Aug 12, 2011 11:10 pm

Okay, since you are using the apple_count method, you need to set it equal to 10 for it to work. So this code needs to go somewhere, perhaps in the view's create actor.
Code: Select all
apple_count=10;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Guys please help me with this problem

Postby raminjoon » Sat Aug 13, 2011 3:16 am

I did exactly as you described but I dont see a text number on the screen like the numbers 1-10 I mean.
raminjoon
 
Posts: 40
Joined: Tue Jul 05, 2011 5:34 am
Location: Denver, Co.
Score: 3 Give a positive score

Re: Guys please help me with this problem

Postby raminjoon » Sat Aug 13, 2011 3:43 am

sorry for asking too much bud but I was wondering to know if you could please do a presentation. I am not dump but honestly am seriously confused please help me out. also this apple is based on create actor like when you press on it, it creates a apple for dragging and replaces it by a clone of it in its original place and all I want is to be able to have the number next to it to decrease and stop at zero. please help me out.
raminjoon
 
Posts: 40
Joined: Tue Jul 05, 2011 5:34 am
Location: Denver, Co.
Score: 3 Give a positive score

Re: Guys please help me with this problem

Postby skydereign » Sat Aug 13, 2011 8:33 am

How do you mean presentation? I can make a ged of what you are asking for, if I could only understand what you are asking for. Originally it sounded like you were perhaps collecting 10 apples, but then it sounded like you were firing them. If you are firing them then at some point you have to set the number of apples to be 10. If there isn't a start to your game, use the view's create actor. For this code, you'll need to create a variable called apple_count.
view -> Create Actor -> Script Editor
Code: Select all
apple_count=10;


This sets the total number of apples you can use, so keeping with the firing bullets idea, it sets your ammo. Now for the text display. It seems you already know how to make a text actor, so make one and give it the following script.
apple_display -> Draw Actor -> Script Editor
Code: Select all
textNumber=apple_count;


This will have the text actor display apple_count, so if you haven't used any apples, it will show 10. The last bit of code has to do with you creating the apples. So I presume this is some mouse button down event, I'll call the actor apple_creator. What this actor will do is on mouse button down, allow the player to drag it around. When they let go, it will create an apple where it was and jump back to its original position, in this code it is (0,0).
apple_creator -> Mouse Button Down (Left) -> Script Editor
Code: Select all
if(apple_count>0)
{
    FollowMouse("Event Actor", BOTH_AXIS);
}

Now on its mouse button up event, have this. It again checks if there are apples to be had, and if so create an apple, reset the position, and decrease the total number of apples.
apple_creator -> Mouse Button Up (Left) -> Script Editor
Code: Select all
if(apple_count>0)
{
    CreateActor("apple", "apple_anim", "(none)", "(none)", 0, 0, false);
    apple_count--;
    FollowMouse("Event Actor", NONE_AXIS);
    x=0;
    y=0;
}


And that should do it. Assuming that is what you want, and you are still having trouble, I can make a ged of it. If this isn't what you meant, you'll have to try explaining it again, or provide the ged you've been working with. Maybe that way I'll understand what you are trying to explain a bit better.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Guys please help me with this problem

Postby raminjoon » Sat Aug 13, 2011 4:50 pm

love you man it worked just like I wanted it but one last thing if you would please help me on it. when I mouse button up this thing, it destroys the apple I want the apple to drop down like yvelocity=5; for example but it destroys it do you know how can I make it to the point that apple drops down instead of dissapearing?
raminjoon
 
Posts: 40
Joined: Tue Jul 05, 2011 5:34 am
Location: Denver, Co.
Score: 3 Give a positive score

Re: Guys please help me with this problem

Postby skydereign » Sat Aug 13, 2011 10:11 pm

Which actor? I have apple_creator (which is the one I put the mouse button up event in), or apple (which currently doesn't have any events)? You said when the apple is let go, apple_creator should jump back to its original position. So, either you mean you want apple_creator to fall to its original position, or the newly created apple should fall. If it is the apple you want to fall edit the script to have this.
Code: Select all
if(apple_count>0)
{
    CreateActor("apple", "apple_anim", "(none)", "(none)", 0, 0, false)->yvelocity=5;
    apple_count--;
    FollowMouse("Event Actor", NONE_AXIS);
    x=0;
    y=0;
}


If it is the apple_creator then not quite sure why you'd do that, but you can just insert a yvelocity=5 into the code, like this.
Code: Select all
if(apple_count>0)
{
    CreateActor("apple", "apple_anim", "(none)", "(none)", 0, 0, false);
    yvelocity=5;
    apple_count--;
    FollowMouse("Event Actor", NONE_AXIS);
    x=0;
    y=0;
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest