Java Programming: Let's Build a Game #8

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

In this video we create a boss for 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 you ever wanted to create games? Have you ever gotten fed up with it being to difficult? Well now is the time to thank me and possibly subscribe because you have just found the channel for you! Game Maker Tutorials, Java Game Programming, Unity3D Tutorials, Batch, C++ and much much more! This is the channel for you, the one stop shop for an exploration of your hidden talent as a game developer. Unleash your potential and go wild with imagination when you finally figure out how to make any game you want!

Visit CodingMadeSimple for more exclusive tutorials and get the help you need to succeed as your very own indie game developer!

Follow me on twitter for exclusive content and interaction with me!

Follow me on Google+ to keep updated with all of my tutorials

Game Maker Studio: Programming
Game Maker Studio: Tutorial
Java Programming
Game Programming
Game Tutorial
Programming Tutorial

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

For Develping purposes, I always had the idea of secret dev features to like regenerate health and stuff. Not only is it fun on multiplayer games(If I ever make one), It's also useful. So, along the way, I recommend you set buttons to say, idk, stop the score timer, directly add bosses, etc. It makes things alot easier when trying to fix bugs, and it's cool to screw around. i have the R key set to reset my health.

yh_hat_trick
Автор

the reason your first clearEnemys() didn't work is because when you removed the item of that index value the item that was next took its place and was essentially skipped easy fix include i-- when an object is removed

andrewcarosi
Автор

Yo this is way late and all but I'm takin a shot at it anyway. How would you go about rendering images? I'm currently trying to do so in my java game but I end up dropping to 7fps when there is more than one image on screen at a time.

MrLingon
Автор

To quickly fix the problem with the value of EnemyBoss.velX, just write
velX += 0.01f*Math.signum(velX);
That should work perfectly

WolfrostWasTaken
Автор

The problem occured at 21.54, is due to the loop. You're actually looping through all of the objects, using i++. Whilst removing an object, the list will shorten, as i increases, which makes the loop skip a few objects. You should always loop from "object.Size() -1" and then decrease i by one, with the condition of i > -1. A conventional for-loop, reversed.

(Example):

for(int i = object.size() -1; i > -1; i(--)){
GameObject tempObject = object.get(i);

if(tempObject.getID() == ID.SmartEnemy || tempObject.getID() == ID.<any enemy>){
object.remove(i);
}

Instead of listing every enemy-type in the condition, you can just say something such as "if ID != player, remove"~~

parenthesis around the double negative, is due to youtubes html-codes..

kallekurttio
Автор

if you want your player to be rainbow do this go to your player class and first thing you have to go to

public void render(Graphics g) {
g.setColor(Color.BLUE);
g.fillRect((int)x, (int)y, 0, 0);
once set those numbers to 0
then go to your trail and delete your trail that you had before
and do this

handler.addObject(new Trail(x, y, ID.Trail, Color.red, 32, 30, 0.05f, handler));
handler.addObject(new Trail(x, y, ID.Trail, Color.orange, 30, 28, 0.05f, handler));
handler.addObject(new Trail(x, y, ID.Trail, Color.yellow, 26, 24, 0.05f, handler));
handler.addObject(new Trail(x, y, ID.Trail, Color.green, 24, 22, 0.05f, handler));
handler.addObject(new Trail(x, y, ID.Trail, Color.blue, 22, 20, 0.05f, handler));
handler.addObject(new Trail(x, y, ID.Trail, Color.magenta, 18, 16, 0.05f, handler));
handler.addObject(new Trail(x, y, ID.Trail, Color.CYAN, 18, 16, 0.05f, handler));
handler.addObject(new Trail(x, y, ID.Trail, Color.PINK, 16, 14, 0.05f, handler));
handler.addObject(new Trail(x, y, ID.Trail, Color.RED, 14, 12, 0.05f, handler));
handler.addObject(new Trail(x, y, ID.Trail, Color.BLACK, 12, 10, 0.05f, handler));

enjoy


}


}

FREE to copy paste!

wolfalpha
Автор

one thing about the timers is that they depend on the fps
(i think)

ethanladwig
Автор

I know this is a few years late, but the entire clearEnemies method can be boiled down to 1 line:

object.removeIf(x -> x.getId() != ID.Player);

This method goes through the entire list and removes any objects that are not the player. No loop needed.

ThePhantomLotus
Автор

For those wondering how he's changing the number in debug mode.. He hits the green bug icon, changes the number in the code, then hits ctrl+s
This lets you modify the program while its still running.

leonidas
Автор

Regarding the issue with enemy removal at 22:00 -> I wondered about what we would have to do if the Player object had more information than it does in this particular game, and what we could do instead to try and remove all the other enemies rather than re-creating the player; I found this to work:

LinkedList<GameObject> deathList = new LinkedList<GameObject>();

for (GameObject tempObject : objects) {
if(tempObject.getID() != ID.Player){
deathList.add(tempObject);
}
}

objects.removeAll(deathList);
deathList.clear();

Any reason this is a bad idea? (Aside from momentarily creating a copy of every enemy object which may be a problem for memory?)

edgarpoefan
Автор

hey man, great series hope you keep with it, I'm waiting anxiously to every episode, and if possible, can you do a video about death of the player? I can't find anything on internet and I'm going insane, can't figure it out!!! I need your help, I can do almost everything by myself, but the death and the menu system is bugging my mind haha.

GPlayerHD
Автор

Ayy i did the same thing with the timer thing but with clamping the y value (only y because it doesn't move left or right) and i used the if statement from before but got rid of the first part from before the ||!!! i finally figured out something awesome i am actually learning from your tutorials they are awesome!

ShadowCooper
Автор

Menu system or game states would be reeeal nice, also, do more tutorials please this one was awesome

FzTxLaNcer
Автор

With Linked Lists it is better to iterate through them backwards in order to avoid the problem that you had it the clearEnemies() method. In other words "for(int i = object.size() -1; i > 0; i--)" is how your for loop should look. I realize this video is 5 years old but just in case someone gets stuck with this.

Phobiac
Автор

Set the 
handler.addObject(new EnemyBoss((Game.WIDTH / 2) - 48, -120, ID.EnemyBoss, handler));
to
handler.addObject(new EnemyBoss((Game.WIDTH / 2) - 48, -160, ID.EnemyBoss, handler));

So just change "-120" to "-160" if you don't want to have that glitch where you can go up and avoid all bullets by boss.. Sorry for my bad English but i hope you understand me :D

pekymanxxx
Автор

I made two players in my game but when the Boss stage arrives, the player2 spawns where the Player1 is located at, how can I fix this so player2 stays where it is at when the Boss stage arrives?

SZakiabba
Автор

Amazing tutorials, your getting me into java :D Will you do more tutorials for it?

gambitdevs
Автор

I have a question on platform games. I am currently trying to recreate a sonic game for practice, and what I am having trouble with are sloped tiles. I'm using a .txt file for my map and basically have either free space or collision. Is it possible using a .txt map file to create sloped tiles? Thanks and I love your videos. There really helpful.

JSkipper
Автор

I love your vids (really informative and interesting) but please use OOP. Instead of copy-pasting every enemy class, create an "Enemy" class that inherits GameObject, and every enemy type will just inherit it

BenMgaming
Автор

Following Carosi's comment I copied my GameObject LinkedList into an ArrayList and it works great now.

Hope this helps :_

public void clearEnemys()
{
List<GameObject> tempList = new

for(int i = 0; i < object.size(); i++)
{
GameObject tempObject = tempList.get(i);
if(tempObject.getId() != ID.Player)
removeObject(tempObject);
}
}

therapy