nice1, your version of intersection/setloc control is a tad easier to read than mine, thanks for the tip :D Here's my nightmare btw,
/**
* different locations gives different conditions, if the characters feet are inside the top half of a block(groundobject)
**/
public void checkFall()
{
int vy = getWorld().getHeight()-2;
if(getY() > vy)
{
death();
}
Actor ground1 = getOneObjectAtOffset(-xGround, yGround, Ground.class);
Actor ground2 = getOneObjectAtOffset(xGround, yGround, Ground.class);
if( ground1 != null)
{
vSpeed = 0;
if((getY()+getImage().getHeight()/2 > ground1.getY()-xGround) || (getY() > ground1.getY()+getImage().getHeight()/2 && onLadder()))
{
setLocation(getX(), ground1.getY()-ground1.getImage().getHeight()/2-getImage().getHeight()/2);
}
onGround = true;
}
else if( ground2 != null)
{
vSpeed = 0;
if(getY()+getImage().getHeight()/2 > ground2.getY()-xGround || (getY() > ground1.getY()+getImage().getHeight()/2 && onLadder()))
{
setLocation(getX(), ground2.getY()-ground2.getImage().getHeight()/2-getImage().getHeight()/2);
}
onGround = true;
}
A new version of this scenario was uploaded on Thu Jan 16 16:58:25 UTC 2014
Added ceilings and wall code.
A new version of this scenario was uploaded on Thu Jan 16 18:09:31 UTC 2014
Updated blocks (and added other styles to the library). Changed base to be exactly 32 pixels apart.
A new version of this scenario was uploaded on Thu Jan 16 19:39:48 UTC 2014
Updated to make subclasses of "Platform" work as walls, blocks, etc.
A new version of this scenario was uploaded on Thu Jan 16 20:59:11 UTC 2014
Added monsters. Currently they just move back and forth on the platform.
A new version of this scenario was uploaded on Thu Jan 16 20:59:56 UTC 2014
Added monsters. Currently they just move back and forth on the platform.
A new version of this scenario was uploaded on Thu Jan 16 23:31:36 UTC 2014
Added shooting [and a shooting manager] and broke monsters into "bad guys". Still need to add sound and more level design. Either a score or a "portal" to the next screen.
A new version of this scenario was uploaded on Mon Jan 27 16:19:35 UTC 2014
Added additional levels and objects. Got shooting to work properly. Changed some graphics.
A new version of this scenario was uploaded on Tue Jan 28 16:28:43 UTC 2014
Forgot to share the source code, apparently. Sorry about that!
A new version of this scenario was uploaded on Tue Jan 28 17:30:13 UTC 2014
Added monsters hitting the walls, fixed the edge glitch, and the monsters now "get" the Player when they touch.
A new version of this scenario was uploaded on Fri Jan 31 17:30:16 UTC 2014
Added a key to open the door. Changed the map layout setup (thanks Danpost!). Added more platforms. Increased commenting code.
A new version of this scenario was uploaded on Fri Jan 31 17:31:59 UTC 2014
Added a key to open the door. Changed the map layout setup (thanks Danpost!). Added more platforms. Increased commenting code. Adding Published source code.
A new version of this scenario was uploaded on Wed Feb 05 17:35:58 UTC 2014
Added a moving platform (still needs some work) and a score counter.
A new version of this scenario was uploaded on Thu Feb 06 19:52:02 UTC 2014
Added the beginnings of the Door class. Still only goes from level 1 to level 2, but it works!
A new version of this scenario was uploaded on Thu Feb 06 20:53:07 UTC 2014
Working on the levels -- which, for some reason, won't go past level 2.
On level 2 on the floor if you walk off the left of the screen you disappear, can't get the guy to come back - I think he has fallen into an endless void.
lordhershey -- Yes, I took out the wall code because I have been working on making it scroll. If I can't get it to scroll, I'll add that back in. Thanks for the feedback, though.
Making a scrolling world that is not a memory hog can be a challenge - I have only made one scrolling game sort and it was not with greenfoot [url=http://www.lordhershey.com/oldSite/debtorman/index.html]debtorman[/url] , what I like about greenfoot is it makes me think outside of my usual box. I would like to make a platform game some time. You can still make a good platform game that does not scroll like this one [youtube]p7SzOzj4s74[/youtube] :)
A new version of this scenario was uploaded on Fri Feb 07 16:50:51 UTC 2014
Thanks to Danpost I figured out the level issue! Woot!
Oh, Danpost. I love you. If my wife and I ever had another kid, I'd name him [or her] Danpost. :)
Seriously, though -- teaching this programming class [which, as I mentioned, was a surprise at the beginning of this year] has been made possible with your help. You've not only helped me, but many of my students. And by showing me better, cleaner, easier methods to do something it makes all of us better programmers.
Thank you very much.
A new version of this scenario was uploaded on Mon Feb 10 17:57:14 UTC 2014
Fixed a bug on the first screen with the key. Began implementing a splash screen -- or attempting it.
Looks good so far, but do you just not want a scrolling screen or have you not been able to do it yet? If it is the latter I could help you with that.
There is some code that is not necessary or too complicated. For example, in the ShootingManager, you have two subclasses when all you really need is one Bullet class (or whatever). What you need a field called speed, and just add that to x like you are. However, in the constructor you could have a field called Direction which is either 1 or -1 (right or left) and then multiply the speed by it.
Also, for the killBadGuys(), you don't need to have two methods for it, you can just call the one method like this:
if (!kill(BadGuys.class))
remove();
This way you call your method and do the remove with much less code so that you can really tell what is going on more clearly. Finally, this code could simply go in the act method because it is succinct enough to not over complicate the method.
Kytuzian -- thank you! The code is a little verbose because it's a tutorial that I am using to teach beginning programming. We've been doing little pieces at a time and the code has begun to be a bit crazy. I have not yet done the scrolling code because I haven't figured out HOW to do it. I would love suggestions! If you're willing you could email me some fixes (griff@kvusd.org) and I would love to see it.
If the scrolling is still something you'd want to implement, for future use when teaching, I've uploaded two scenarios. The first (http://www.greenfoot.org/scenarios/12055) is a simple scrolling demo where I use a fictive cam that pans over the level (which i belive is the most intuitive way to implement scrolling), and the other is a platformer game demo using the first scrolling mechanism, aswell as some other functionality that I think can be fun examples to teach :) The game demo is scenario 12048
If you're interested and have any questions or want better commented code you can just Contact me on karlars [at] live.se if Im not Active on here
Not sure I'm going about this the right way but i'm using your map concept and am struggling with adding an actor. I think it has something to do with the constructor i used but i'm not sure how to fix it. I'm pretty sure I need the constructor to re-size my images.Using other things to re-size them always seems to distort the images.
Thank you for uploading this, I am using this to help develop my own platformer for my college course. However, one problem I am having currently is that my actor can't collide/jump on platforms and doesn't stand on top of the ground. Since I am still new, I don't know what code you used. If you could help me with this, I would be very grateful!
it is good but very jumpy. If i were you i would make the movement use some sort of velocity. For example: Every frame the xSpeed can go up by 1, and it stops going up at like 8 xSpeed. And when you let go the xSpeed goes down by 1 until it hits 0, then it stays 0. Makes the game smoother :)
2014/1/13
2014/2/6
2014/2/6
2014/2/6
2014/2/7
2014/2/11
2014/2/11
2014/8/19
2014/10/1
2014/10/1
2015/3/12
2015/3/12
2017/3/1
2017/4/5