You can chack my TowerDefence Java game, i`ve made it in 6 days(2 for map editor 4days for game, it is still in progress) you tube . c o m \ watch?v=9EM4P4Nztfs&feature=channel_video_title
@treeclimbingkid yes he used something else to make it, yet with your 3rd question, just add a new frame or make a new movie clip to contain the next floor, and program accordingly.
one question how do i make it so the player collides correctly with blocks? on many attempts at a platformer he would be able to fall through certain places, jump up or get stuck in the middle of a block. please help!
1) Approximate player by rectangle, check if rectangles intersect.
2) Divide player movement into many 1-pixel moves. Process them while they are possible (while there is no collision with any wall after move). If next move is not possible, set player speed to zero.
3) Semipermeable platforms: detect collision with them only if initially player's feet are above their surface.
The description contains a link to article, which contains a link to source code.
@Viliam1234 the link takes at least an hour to load and gives me error messages. but would i use a for loop using the speed, then cap it off at the first collision? or would that be too high on cpu (considering the large number of tiles possibly used) ?
@forrest0no Computers are incredibly fast these days, don't underestimate them! A for-loop will run in a microsecond. Code first, optimize later -- usually the optimization won't be necessary.
In my game, there are only a few tiles, so I check them all. If you have thousands, perhaps try to divide the area into segments (some tiles will be in multiple segments). Then only check tiles in segments that intersect with player rectangle. Remove 90-99% tiles by a rough guess, then check the remaining.
@Viliam1234 thanks, and also the multi comment, youtube was being really stupid and saying i couldnt post. so it lied. again. Well thank you alot for the help!
@Viliam1234 I cant get the link to work... Oh but since i want the player to move considerably fast, could i use a for loop, goal being the speed, and check each situation and cap it off once it finds an impossible situation?
See the DESCRIPTION. It was made in Java (no actionscript). The video is recording of me playing the game. I play the blue man; the snails and platforms move automatically.
In the linked article there is a link to download source code. Each level is constructed from individual pieces (walls, floor, snails, apples, platforms). Their starting positions are described in source code (in a perfect world, they would be in configuration file), then they move according to rules.
Very simply -- rectangle with rectangle. ;-) Both the hero and snails have approximately rectangular shapes. Also walls and platforms. The formula for collision between rectangles is:
You can chack my TowerDefence Java game, i`ve made it in 6 days(2 for map editor 4days for game, it is still in progress) you tube . c o m \ watch?v=9EM4P4Nztfs&feature=channel_video_title
jahpengu 6 months ago
@treeclimbingkid yes he used something else to make it, yet with your 3rd question, just add a new frame or make a new movie clip to contain the next floor, and program accordingly.
forrest0no 7 months ago
one question how do i make it so the player collides correctly with blocks? on many attempts at a platformer he would be able to fall through certain places, jump up or get stuck in the middle of a block. please help!
forrest0no 7 months ago
@forrest0no
1) Approximate player by rectangle, check if rectangles intersect.
2) Divide player movement into many 1-pixel moves. Process them while they are possible (while there is no collision with any wall after move). If next move is not possible, set player speed to zero.
3) Semipermeable platforms: detect collision with them only if initially player's feet are above their surface.
The description contains a link to article, which contains a link to source code.
Viliam1234 7 months ago
@Viliam1234 the link takes at least an hour to load and gives me error messages. but would i use a for loop using the speed, then cap it off at the first collision? or would that be too high on cpu (considering the large number of tiles possibly used) ?
forrest0no 7 months ago
@forrest0no Computers are incredibly fast these days, don't underestimate them! A for-loop will run in a microsecond. Code first, optimize later -- usually the optimization won't be necessary.
In my game, there are only a few tiles, so I check them all. If you have thousands, perhaps try to divide the area into segments (some tiles will be in multiple segments). Then only check tiles in segments that intersect with player rectangle. Remove 90-99% tiles by a rough guess, then check the remaining.
Viliam1234 7 months ago
@Viliam1234 thanks, and also the multi comment, youtube was being really stupid and saying i couldnt post. so it lied. again. Well thank you alot for the help!
forrest0no 7 months ago
@Viliam1234 I cant get the link to work... Oh but since i want the player to move considerably fast, could i use a for loop, goal being the speed, and check each situation and cap it off once it finds an impossible situation?
forrest0no 7 months ago
Just finished updating my java game and a zip with a jar and all the resources is online!! It's on my channel.... check it out
(youtube..dot..com) /watch?v=-3I_hUg06Dg
kylecowan990 9 months ago
@treeclimbingkid
See the DESCRIPTION. It was made in Java (no actionscript). The video is recording of me playing the game. I play the blue man; the snails and platforms move automatically.
In the linked article there is a link to download source code. Each level is constructed from individual pieces (walls, floor, snails, apples, platforms). Their starting positions are described in source code (in a perfect world, they would be in configuration file), then they move according to rules.
Viliam1234 10 months ago
Cool! But when I have gravity and hit a platform i cant move anymore :( plz help ):
arcanists2000 1 year ago
Nice and fun to see.Keep it up!.Are u using threads in this game?is it java2d ?...
Maxmetallica 1 year ago
oh god please show me how to do a platform or give me a source for it
nineballssj9 1 year ago
@nineballssj9
use a sprite sheet and use and array for map
liek int[] map = {0,0,0,0},{0,0,0,0}....; as big as you want and use
g.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer)
you have to know how many pixels tall and wide each image in the spritesheet is
ramosjrIFZ 1 year ago
nice. nothing bad to say.
joutupp 1 year ago
Viliam1234, personally for collision detection I prefer to create two rectangle instances and use the intersect method on them.
I.E:
Rectangle rect = new Rectangle(player.getX(), player.getY(), player.getWidth(), player.getHeight());
Rectangle apprect = new Rectangle(apple.getX(), apple.getY(), apple.getWidth(), apple.getHeight());
if(apple.intersects(rect)) { return true;
}
return false;
JavaCod3r 1 year ago
good job
alexios123 1 year ago
how you made collisions?
Neomex000 2 years ago
Very simply -- rectangle with rectangle. ;-) Both the hero and snails have approximately rectangular shapes. Also walls and platforms. The formula for collision between rectangles is:
if ((a.left < b.right) && (b.left < a.right) && (a.top < b.bottom) && (b.top < a.bottom) { collision(a, b); }
Viliam1234 2 years ago
@Viliam1234 Thank you!
drek507 1 year ago
Amazing! Only 4 days in java... Very proficient!
TheBatchGuy 2 years ago
@TheBatchGuy I'm assuming he already knew java, and he made this in 4 days.
FrozenIceCweam 1 year ago
Nice work, I'm writing my own platform game engine right now. Only just started and it's not as advanced as even yours yet! ;-P
amcadam26 3 years ago
Beautiful work, takes me back to the old 8-bit when i was meant to be doing my homework and instead played games like this! Thanks! keep it up :)
Pablos544 3 years ago