This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#26 2012-04-12 22:40:54

backspace_
Scratcher
Registered: 2012-03-21
Posts: 500+

Re: Detection with guards.

aegisrunestone wrote:

A separate script? So, something like...

when I receive [BeginPatrol]
forever
if touching (Wall)
turn cw (90) degrees
move (-10) steps
Like that?

don't make wall a variable, use the sprite "wall"

when I receive [BeginPatrol]
forever
if touching [Wall]
turn (90) degrees
move (-10) steps


Your tiny hands
Your crazy kitten smile

Offline

 

#27 2012-04-13 10:29:34

aegisrunestone
New Scratcher
Registered: 2012-04-08
Posts: 34

Re: Detection with guards.

Um... yes, that's what I did. I didn't know how to put it up in code here as a sprite. But, I DID use a sprite.

Offline

 

#28 2012-04-15 23:00:31

aegisrunestone
New Scratcher
Registered: 2012-04-08
Posts: 34

Re: Detection with guards.

Sonicfan, did you ever get your version of the game built?

Offline

 

#29 2012-04-16 00:04:45

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Detection with guards.

I'm working on it, but it's a bit more complex than I thought. I should have it done soon, don't worry.

Last edited by sonicfan12p (2012-04-16 10:45:17)


Why are the secret organizations getting all the attention?  mad

Offline

 

#30 2012-04-16 09:28:37

aegisrunestone
New Scratcher
Registered: 2012-04-08
Posts: 34

Re: Detection with guards.

Yeah, it's very complex. XD

Offline

 

#31 2012-04-16 20:45:15

aegisrunestone
New Scratcher
Registered: 2012-04-08
Posts: 34

Re: Detection with guards.

Okay, here's what I have so far now.

Guards will chase you, unless you're behind a wall, then they just ram into the wall repeatedly.

http://img256.imageshack.us/img256/5395/acguard2.gif

Oh yeah, I added a script that's not in that image. It basically bounces the guards off Ezio if they are touching him.

http://img841.imageshack.us/img841/650/ezioscript.gif

And this is Ezio's insanely long script.

The game basically works. The only issues I have is:
1) Guards don't chase you properly.
2) Collision detection between guards and Ezio stinks. Making it hard to die.
3) Haystacks don't work (and I can't figure out how to make them work).

Any ideas?

Offline

 

#32 2012-04-16 22:35:09

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Detection with guards.

Okay, it's done! Here it is. I hope this helps!  big_smile


Why are the secret organizations getting all the attention?  mad

Offline

 

#33 2012-04-17 09:56:26

aegisrunestone
New Scratcher
Registered: 2012-04-08
Posts: 34

Re: Detection with guards.

That's AWESOME.

But the Haystacks don't work. I tried to hide in one, and the guard still chased me.

Offline

 

#34 2012-04-17 11:14:18

aegisrunestone
New Scratcher
Registered: 2012-04-08
Posts: 34

Re: Detection with guards.

Oh, okay. The haystacks do work as long as you HOLD the space bar key.

Is there a way to make it so if you just press the space bar key that Ezio hides until you press it again?

Offline

 

#35 2012-04-17 11:16:15

BetaSmozzick
Scratcher
Registered: 2012-02-25
Posts: 51

Re: Detection with guards.

Maybe add a variable called hidden?

Then at the start of the patrol where it has if detected = 0 and patrolling = 1 add and hidden = 0.

Put elsewhere when touching haystack hidden = 1.

Of the code I saw in the images I didn't see anything for the haystacks?

Offline

 

#36 2012-04-17 11:19:15

BetaSmozzick
Scratcher
Registered: 2012-02-25
Posts: 51

Re: Detection with guards.

Ah, downloaded that other project and that does have a hiding variable.

To make it hide just when clicked get rid of the not key space pressed part.

You'll have to make it so that when you move it sets hiding to 0 though or that you cant move while hiding and pressing space again sets it to 0.

Offline

 

#37 2012-04-17 11:23:35

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Detection with guards.

aegisrunestone wrote:

Oh, okay. The haystacks do work as long as you HOLD the space bar key.

Is there a way to make it so if you just press the space bar key that Ezio hides until you press it again?

I thought about that, and I tried to make it work, but if it is possible, it's a whole lot more complicated than I have time to accomplish it.  sad  Sorry.


Why are the secret organizations getting all the attention?  mad

Offline

 

#38 2012-04-17 11:39:06

BetaSmozzick
Scratcher
Registered: 2012-02-25
Posts: 51

Re: Detection with guards.

aegisrunestone wrote:

Oh, okay. The haystacks do work as long as you HOLD the space bar key.

Is there a way to make it so if you just press the space bar key that Ezio hides until you press it again?

Here:

Link to Project

Offline

 

#39 2012-04-17 13:37:39

aegisrunestone
New Scratcher
Registered: 2012-04-08
Posts: 34

Re: Detection with guards.

BetaSmozzick wrote:

aegisrunestone wrote:

Oh, okay. The haystacks do work as long as you HOLD the space bar key.

Is there a way to make it so if you just press the space bar key that Ezio hides until you press it again?

Here:

Link to Project

COOL! I'll put that into my project ASAP.

Offline

 

#40 2012-04-17 17:42:52

aegisrunestone
New Scratcher
Registered: 2012-04-08
Posts: 34

Re: Detection with guards.

http://img692.imageshack.us/img692/2063/acguardenhanced.gif

Okay, I'm having problems, note the guard's starting position. Now, he goes flying down the screen and off the level into the corner and stops. He does chase Ezio--sortof--but he's stuck. How do I fix this?

Offline

 

#41 2012-04-17 18:32:03

BetaSmozzick
Scratcher
Registered: 2012-02-25
Posts: 51

Re: Detection with guards.

Hard to say without being able to see the project, sorry.

Not sure if its relevant but try double clicking the green flag when you start the project.

Offline

 

#42 2012-04-17 19:01:28

aegisrunestone
New Scratcher
Registered: 2012-04-08
Posts: 34

Re: Detection with guards.

That doesn't do a thing to help me.  hmm

Hang on, I'll upload the project to one of my sites and I'll post it here later.

Offline

 

#43 2012-04-18 06:09:52

BetaSmozzick
Scratcher
Registered: 2012-02-25
Posts: 51

Re: Detection with guards.

Ok, post when its uploaded and I'll check it out.

Offline

 

#44 2012-04-18 12:31:29

aegisrunestone
New Scratcher
Registered: 2012-04-08
Posts: 34

Re: Detection with guards.

http://therunestonelibrary.com/storage/AcCTFAVSGB.sb

Here it is.

Offline

 

#45 2012-04-20 10:50:02

aegisrunestone
New Scratcher
Registered: 2012-04-08
Posts: 34

Re: Detection with guards.

Uhh... o.o

Offline

 

#46 2012-04-20 12:53:28

BetaSmozzick
Scratcher
Registered: 2012-02-25
Posts: 51

Re: Detection with guards.

Downloading now to check it out. Was ill recently, sorry.

Offline

 

#47 2012-04-20 12:57:02

BetaSmozzick
Scratcher
Registered: 2012-02-25
Posts: 51

Re: Detection with guards.

SOLUTION BELOW


Ok so here's whats happening:

First, the bug is this:

Guard 1 appears and falls down the left hand side.

The reason is this:

It's start y location is 33.

Going straight into the first bit of the code it says to change y by -5 until y > 35. This never happens so the guard gets stuck into a loop where it falls forever.

The fix:

Change one of the if statements conditions.

In depth fix is below.

---

EDIT: OK, trying to apply that fix now and its troublesome o.O

EDIT2: OK, got it patrolling.

Remove the set y to 33 and -100 blocks, unless you can work out how to apply them properly here unlike me.

Set the top if to y posititon < -100.

Done.

Last edited by BetaSmozzick (2012-04-20 13:21:03)

Offline

 

#48 2012-04-20 14:57:46

aegisrunestone
New Scratcher
Registered: 2012-04-08
Posts: 34

Re: Detection with guards.

Thanks! That works great!  big_smile

Another problem: the guard won't chase Ezio, though, when he gets in range.

Offline

 

#49 2012-04-20 22:07:49

BetaSmozzick
Scratcher
Registered: 2012-02-25
Posts: 51

Re: Detection with guards.

Nearly certain that that's because you didn't put code in for that guard. I'll check, though.

EDIT: Ok, it's an IF statement problem again.

In BeginPatrol on guard1 you:

1. check if detected is 0 or ezio is out of range
That's fine
2. check if detected is 1 and ezio is within range
The problem here is either that the AND should be an OR - I don't think it's this
or that you haven't coded  in a way to make detected = 1 - this seems like the problem

---

In fact I think you could fix it by removing the bit that says AND distance to ezio < 100 but leave in the detected check.

Then above the 2 current IF statements put in:

if <(Distance to [Ezio v]) < [100]>
set [Detected v] to [1]
end
OK the idea above wouldn't quite work with an if else because its use for all of the guards...not sure how to fix that...instead just use the distance to ezio < 100 thing instead of detected, maybe?

Last edited by BetaSmozzick (2012-04-20 22:41:35)

Offline

 

#50 2012-04-21 14:57:50

aegisrunestone
New Scratcher
Registered: 2012-04-08
Posts: 34

Re: Detection with guards.

Okay, I'll try that.

BTW: How do you edit posts?

Offline

 

Board footer