Java Game Programming Wizard Top Down Shooter Part 5

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


• Course Selection •

• Individual Game Design Courses •

Have fun learning!

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

I would like to assure you all, three years later, that despite some trial and error and frustration, it is very possible to get this running.
There are no errors in this code, not only that, it is explained quite clearly. I got this to run up to the current point.
Like everyone said if you are having errors it has to do with your package dependencies, the pixels size of your PNG and it's RGB color codes. Make sure its 64 x 64 and using base color codes.

rmdir
Автор

Can someone plz explain why half o f the screen renders over the player and how to get it to not...

Ghst-y
Автор

I thought photoshop would be great for the level creation however I then realized that Gimp has pixel-based rulers which really helped me out.

geetanshgautam
Автор

For those dealing with a CME (concurrent modification error) in their code, move the start of the render thread below the loading of the level. The reason this error occurs is because of a race condition between the main thread trying to loadLevel(level) and the render thread performing rendering. Simply starting the render thread after the level has been loaded into our LinkedList will solve this race condition.

FineLineFiring
Автор

@RealTutsGML I set everything correctly, including the name and I, even used paint.net!

SvsJFaceoff
Автор

If you are having problems showing up the image. Please use specific colors RGB into your paint program that you are using. Example: for red use color settings red=255 green=0 blue=0, for blue use red=0, green=0, blue=255. Instead the code if(red == 255) and if(blue== 255) will not work.

dougg
Автор

Decided to make a more easily expanded tileset. If I wanted to add 20 different types of tiles, you'd have far too much to keep track of.

My idea was to create a legend at the bottom of the screen. Then have the program compare each pixel to the legend. The problem is image.getRGB(x, y) returns bit values to turn 3 numbers into 1. The issue is that 1 number can be and is often the same no matter the color.

My Solution? Create a new function which converts an x, y position in an image to an up to 9 digit int.

//script
private int trueRGB(int x, int y, BufferedImage img) {
int testPixel = img.getRGB(x, y);
int red = (testPixel >> 16) & 0xff;
int green = (testPixel >> 8) & 0xff;
int blue = (testPixel) & 0xff;
int trueRGB = red + (green * 100) + (blue *

return trueRGB;
}

private void loadLevel(BufferedImage image) {
int w = image.getWidth();
int h = image.getHeight();


int floorPixel = trueRGB(0, 63, image);
int playerPixel = trueRGB(1, 63, image);
int wallPixel = trueRGB(2, 63, image);
//int (tile)Pixel = trueRGB(x, y, image);

for(int xx = 0; xx < w; xx++) {
for(int yy = 0; yy < h; yy++) {
int pixel = trueRGB(xx, yy, image);

if(pixel == playerPixel) {handler.addObject(new Player(xx * 32, yy * 32, Color.blue, ID.Player, handler));}
else if(pixel == wallPixel) {handler.addObject(new Wall(xx * 32, yy * 32, ID.Wall));}
//else if(pixel == (tile)Pixel {handler.addObject(new (Tile)(etc))}
}
}
}

The_Foreman
Автор

No errors but my object wont move, and i have to close forcibly the window in the task manager. What's up with the problem?

jhonnasvisitacion
Автор

I had problems making the level picture with Photoshop; it changed the color levels to 250 instead of the 255. With GIMP it worked. I don't know why Photoshop changed the values a bit.

MichaelStoegner
Автор

Really Nice Tutorial This is good for upcoming developers :)

Goatnime
Автор

Another great video! Keep up the great work!

AROD-ohez
Автор

@RealTutsGML Can you please help us a bit. I have everything setup correctly but I'm getting only a Red screen.

hero
Автор

hey man i want to find people to work with and make a game but the thing is i dont know where to find anyone so can you help me find people or tell me where to find them ???

rocky
Автор

I have figured out several mistakes in the codes in this video. I think that either he was running a different code project or fixed those errors and didn't correct them in this video :) . Following exact same codes he has written, there is a concurrency error and looks like that the loadLevel that is supposed to add objects to the handler's linked list is getting called after, not before the rendering begins

hero
Автор

Can someone explain to me why in loadLevel method (when adding game objects) we have to multiply 'x' and 'y' by '32'? I mean why 32 and not a diffrent number.

hdwdctv
Автор

Can't get this to work, I've checked the code 15 times and can't see any differences. I just get the red background now, no blocks or player loading in.

jame
Автор

Where have you got this knowledge from?

MichaelStoegner
Автор

for me when i run it i only have an entirely red window. i also checked the png file if the colors are all set true (255 for red and blue each). anybody can help?

cpt_meric
Автор

Why did you shift red by 16?? Please someone help

saladgaming
Автор

Following this has been fun but I'm stuck.
I'm having a problem with the "/wizard_level.png" file.
I used photoshop first but it has too many options for saveing and created an error message so i deleted the copy in my res file.
I then used paint to draw and save the png file and loaded that. I receive no errors now but the program still fails to display the game objects.
I'm using only rgb colors and I made the code identical.
What could be wrong?

tttreyflip