Java Beginner Tutorial - Basic Collision

preview_player
Показать описание

In this video we learn how to create basic collision in our game. If you have any questions then be sure to leave a comment or contact me on twitter; realtutsgml. If you learned something then be sure to leave a like, comment, and favorite.

Have fun learning!

Рекомендации по теме
Комментарии
Автор

i found a cool thing you can do if you change it to negative
if(x > 613){
x = -613;
}
if(y > 457){
y = -457;
}
then that makes it go back to the other side so its not that it bounces off its that it swaps to the other side to you go through the right side and you come out of the left :) its nice it works with the bottom aswell

WoWAsteros
Автор

Hey man glad your making these videos again, but same problem as last video. with having to press tab before the arrow keys working/being able to move, could you tell me whats wrong or address this in your next video? Thanks

TheRoach
Автор

make sure you have setFocusable(true) in the constructor for Game class

RealTutsGML
Автор

It was never my opinion that it was your fault, obviously the problem was at my end. Did some research about java development on a mac (especially gamedev) and from what I found some things are done quite differently, had somthing to with java security restrictions among other things. So I used bootcamp and installed windows 7 ult 64bit, started over and now everything works perfectly and I´m back on track :)

TechBoxNorth
Автор

Still having problems with the arrowkeys ( I have setFocusable(true) ) but if I set to "x += 5" and so on it works but with absolutely horrible performance.. imagine trying to play BattleField 3 on a pocketcalculator... :( just spent the equivalent of 3000USD on this new iMac and it plays BF3 (using bootcamp) like a dream! and the same with diablo3 & guildwars 2.

TechBoxNorth
Автор

Would this laziness slow the game?
if(x>640-32){
x=640-32;
}
if(y>480-32){
x=480-32;
}

Ltezpeed
Автор

how about public void update (Mainclass g)

{
if (x+xp==g.getheight())
{
xp=0;
}
}

kamalahmad
Автор

I think it looked weird on the lower left sides of the screen because the sprite is centered at the upper right corner.

taylorkohls
Автор

ahh alright I am glad to hear that. Yeah I wasn't aware that you were using mac.

RealTutsGML
Автор


Hey dude the reason the collision was off was because the width and height take into account the bar at the top which is 22 pixels or something :)

mangoac
Автор

well this is not my fault. Sorry to say but you messed up your code BAD!! I use this same key input method in all of my games and they run smooth at 100 fps and those are big games. Maybe set your timer lower or calculate your fps.

RealTutsGML
visit shbcf.ru