This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

FlyingRabidUnicornPig
FlyingRabidUnicornPig presents ...

2013/11/10

Locking

Something I've been working off and on the last couple weeks. A locking mechanism for Greenfoot, allowing objects to "lock" on to other objects, rotate around them, and follow them. I've had really bad problems with rotating around objects, and I hope I can get these fixed. (Game/maniac has offered to help out with that, thanks!)
I'm working on a little demo, where you control the guy and have him move around through the different uses of locking, but I'm not done. Just enjoy moving this guy around, and play around with moving the different parts of his body and see what happens.

1742 views / 3 in the last 7 days

2 votes | 0 in the last 7 days

Tags: demo with-source

open in greenfoot
Your browser does not support the canvas tag.
Game/maniacGame/maniac

2013/11/10

I could help you with your rotation problem just put up the source code :).
Sure, I'll do that, I wanted to upload source with the demo, but if you could help out, that'd be great. I should explain thoroughly what the problems really are: So I want the locked objects to move around the object they're locked onto when it rotates, and it mostly works, it's just that it'll go much faster on the top half or bottom half (depending on what way it's rotating), and also, if the objects are really close to the one they're following, they'll stop moving around the object directly to the right of it. I sorta understand why this happens (move(), even after making it work with double values in SmoothMover) but whenever I try to use the trigonometry that works on paper to find the next spot to move to, it doesn't work when I code it out in greenfoot. Also, the object doesn't rotate as well as it should, for example, it should always have one part of the object facing the center object, and it sorta does, until it goes to the faster part. You'll find the rotation part of the code in LockActor.class There's probably other problems I haven't noticed, but I've only screwed around with using FollowWorld, and that's what I've noticed. Everything works well, but rotating around the object. Thanks for your help!
A new version of this scenario was uploaded on Mon Nov 11 01:24:27 UTC 2013 Uploaded Source
bournebourne

2013/11/11

I've done something similar to this but not with Actors, in my Pyro scenario. Nice job!
A new version of this scenario was uploaded on Mon Nov 11 15:10:07 UTC 2013 Improved walking demonstration, and also it demonstrates locking better. Added an accurate step counter. Implemented psuedo-scrolling world. Counter showing current location (as int, not double) Walk forward to test out "Special Text" (Stops in middle, fades out)
Also, with latest update, the text only moves if you are moving.

Want to leave a comment? You must first log in.

Who likes this?

bourne Game/maniac