Need help with a problem

Non-platform specific questions.

Need help with a problem

Postby jcflysrc » Wed May 04, 2011 8:22 am

Hi all, my first post here, so YES, I'm a noob. But anyway, I'm trying to figure out how to make an actor, an arrow, come from the side of the view at random intervals. I'm trying to build a platform game, and I can't figure it out. My wish is for it to come randomly, and at different places on the screen with regard to y coordinates. Not too fast, but not too slow either. I did the Moon Defender tutorial so I kinda got an idea about it, but I need the arrows to track straight across the map, like an arrow would. Any help is greatly appreciated. Thanks in advance. Also how do I make the snakes in the caveman tutorial move from one side of the platform and then change animation direction, and go back to the other side. For some reason the tutorial gets to a point and then just kinda does some erratic mouse pointer movements, and then ends. Again thanks. Peace!
jcflysrc
 
Posts: 49
Joined: Wed Apr 27, 2011 9:56 am
Score: 0 Give a positive score

Re: Need help with a problem

Postby skydereign » Wed May 04, 2011 6:59 pm

For the first question, you can use a timer set to random. The attatched image will create a timer (make it for the view) that triggers anytime from 1-2 seconds. On the timer event from the view, use the following code.
view -> Timer (createArrows) -> Script Editor
Code: Select all
CreateActor("arrow", "arrow_left", "(none)", "(none)", width, rand(height), false)->xvelocity=-2;


Just in case, at the end of the CreateActor, I put ->xvelocity=-2, which all that does is take the actor you just created and sets its xvelocity to -2. That way it will be moving, without the create actor event.

To answer your other question, people tend to just have the snake either move a certain distance, time, or have wire regions to signify when to turn. Their are other ways, so if you want something better just ask.
Attachments
randomTimer.png
randomTimer.png (8.68 KiB) Viewed 1750 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Need help with a problem

Postby jcflysrc » Wed May 04, 2011 9:49 pm

Thank you sir, I'll try that now. I knew it was probably something simple like that. I am getting a good feel for GE, but my coding still leaves a lot to be desired. I'm learning though. :wink:
jcflysrc
 
Posts: 49
Joined: Wed Apr 27, 2011 9:56 am
Score: 0 Give a positive score

Re: Need help with a problem

Postby jcflysrc » Wed May 04, 2011 11:53 pm

Ok, Im stumped. I tried to apply the actions you described, but obviously I am not doing it right. Could you break it down step by step...you know, click this, add that sort of thing. Sorry to be a pain but I'm not getting it.
jcflysrc
 
Posts: 49
Joined: Wed Apr 27, 2011 9:56 am
Score: 0 Give a positive score

Re: Need help with a problem

Postby skydereign » Thu May 05, 2011 12:11 am

Sure, I'm assuming you mean the random arrows. Attached is a ged of the following.

1. Go to the view actor.
2. Add event CreateActor, select Script Editor.
3. Click [variables/functions], select CreateTimer.
4. Select New Timer.
5. Set name to createArrows, Timer to 3000 ms, Type to random, minimum time to 1000. Click [Ok].
6. Click [Ok] to add the timer.
7. Click [Ok] to add the script.
8. Create a timer event for the view using createArrows.
9. Type in this code.
Code: Select all
CreateActor("arrows", "arrows_left", "(none)", "(none)", width, rand(height), false)-> xvelocity = -2;

10. Add that script and it should work.
Attachments
arrows.ged
(1.07 KiB) Downloaded 63 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Need help with a problem

Postby jcflysrc » Thu May 05, 2011 2:45 am

1. Go to the view actor.
2. Add event CreateActor, select Script Editor.
3. Click [variables/functions], select CreateTimer.
4. Select New Timer.
5. Set name to createArrows, Timer to 3000 ms, Type to random, minimum time to 1000. Click [Ok].
6. Click [Ok] to add the timer.
7. Click [Ok] to add the script.
8. Create a timer event for the view using createArrows.
9. Type in this code.

Code: Select all
CreateActor("arrows", "arrows_left", "(none)", "(none)", width, rand(height), false)-> xvelocity = -2;

I am doing exactly the above sequence of events, except I am assuming that after step 7, I am to click on ADD//Timer//then select "createArrows timer event", and then Script Editor? That's what I tried, and I put in the code you gave me, but no arrows. I managed to get one arrow in a stationary position on screen, but no movement, and no random arrows. I have the arrow actor set to "no" on create at startup. What am I doing wrong?
jcflysrc
 
Posts: 49
Joined: Wed Apr 27, 2011 9:56 am
Score: 0 Give a positive score

Re: Need help with a problem

Postby skydereign » Thu May 05, 2011 2:56 am

I don't know. Those steps are exactly what I did to create that ged. Have you tried looking at the ged?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Need help with a problem

Postby jcflysrc » Thu May 05, 2011 3:40 am

Yes I did and it worked fine, except maybe too many actors, but otherwise it was good. I just cant identify what I'm doing wrong.
jcflysrc
 
Posts: 49
Joined: Wed Apr 27, 2011 9:56 am
Score: 0 Give a positive score

Re: Need help with a problem

Postby skydereign » Thu May 05, 2011 5:03 am

Okay, I think I figured it out. One thing that you should be doing different is if your actor is not named arrows, or does not have an animation arrows_left, it will mess up, but I assumed you changed them to fit your game. If not, then in future that is something to look out for. Since we don't have your setup, we can't use the exact names that you use, and therefore you have to translate them. So, chances are the either the arrows actor is named differently and/or the animation is.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Need help with a problem

Postby jcflysrc » Thu May 05, 2011 5:30 am

Possible, I will check that aspect to be sure. Thanks for your help so much, and stay tuned, I will let you know if I get it going.
.
jcflysrc
 
Posts: 49
Joined: Wed Apr 27, 2011 9:56 am
Score: 0 Give a positive score

Re: Need help with a problem

Postby jcflysrc » Thu May 05, 2011 8:13 am

Ok, I got the arrows to show up. But they are always at the top of the view, just barely visible, and way too many of them. Als, one arrow is always displayed in the middle of the view in a static way, doesn't move. Getting close. Basically I want the arrows to be a menace to my character so that if he collides with them he will die. So anyway, thanks for your help!
jcflysrc
 
Posts: 49
Joined: Wed Apr 27, 2011 9:56 am
Score: 0 Give a positive score

Re: Need help with a problem

Postby skydereign » Thu May 05, 2011 8:21 am

To note, the frequency that they are created can be altered. If you notice, when creating that timer, you set a minimum and maximum time. The arrow will be created sometime between the two, so if they appear too frequently for you, then just change those. Not sure why they are only appearing at the top, but if you wanted it just to be in the more middle section of the screen, you can change the y value of the create actor.
Code: Select all
CreateActor("arrows", "arrows_left", "(none)", "(none)", width, height/4+rand(height/2), false)-> xvelocity = -2;


This will create them only from 1/4 of the screen height, to 3/4. Make sure the x and y coordinates in the code you have are like the ones above.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Need help with a problem

Postby jcflysrc » Thu May 05, 2011 9:12 am

Yea! I got it. I added an Actor named Bow, and cloned him twice, and distributed his position evenly across screen from top to bottom, and put him off screen. I used him to create the Create Actor//Create Timer event. I had to change the names in the script, as you suggested to match my files, and I increased the velocity to -10. I increased the values from 3000ms, and 1000ms, to 12000ms, and 1000ms. Now the arrows come out nice and evenly spaced at a decent speed. Thank you so much for your help. I really do appreciate it. +1 to you!
jcflysrc
 
Posts: 49
Joined: Wed Apr 27, 2011 9:56 am
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest