Java Game Programming #11 - Level Design

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


Have fun learning!

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

Glad you're staying with the series unlike many Youtubers who start series and ditch them once their views start to dip. I'll try to support you by liking your videos, and I certainly hope others do as well. 

Tedsta
Автор

I couldn't avoid jumping for joy when I saw my code working when it loaded the image... thank you so much! You've helped us very much.

jesusparra
Автор

Genius! before watching this tut, I had to manually make my own "level maker" app!

YuZhengwen
Автор

pixel is an int

an int has 4 bytes in it, each byte has 8 bits in it

example : 0xA3 0x41 0x28 0x76

that's an example of a pixel (1 int with 4 bytes, 32 bits at all)

Now packed in this pixel is information about the transparency (A) the red, green and blue components.

The transparency is the first byte (0xA3) then red (0x41) then green (0x28) then blue (0x76)

so to get just the red part out, you shift to the right by 16 bits, which gives

0x00 0x00 0xA3 0x41

now the red is the right most spot, but you got that transparency byte there, which isn't good, so you have to remove it

doing & 0xFF, is really

0xA341 & 0x00FF

which means you and each bit, so the bits of A3 are ended with 00 which gives 0, and the bits of 41 are ended with FF which since FF is all ones, gives you the original value, which is 41

so red is

0x00 0x00 0x00 0x41

So this code, is pulling out each component by itself from an integer.


Say modest thanks :*

yesno
Автор

Any one having trouble loading their level. and getting the null pointer exception in your console. it's because handler = newHandler(); was moved off camera. Happens in just about every game tutorial I watch. I think it happens because they have to prepare exactly what their gonna do before recording so their not trying to figure everything out on the fly. anyway he moved that.  You should have these 3 things in this order in Game class.    handler = = newCamera(0, 0);               LoadImageLevel(level); I think as long as you create a new handler before LoadImageLevel is the important part. Took me a while to figure out. and I see there are a bunch of people that had this same issue. Didn't see them getting any help. I hate that.

jasonzimmerman
Автор

Thank you, ive been waiting for this video for a long time! Keep up the great work, and if it's at all possible, please post java platformers more frequently

ashwinkkudva
Автор

when it works for the first time and once you realise how simple it is to create a LOT of levels thanks this method, it's JUICY!

sunsigne
Автор

Great tutorials!!
When did you fix the "sticky" movement?Did I miss it?

guyshuster
Автор

AMAZING!!! I'm following the entire series.
It's fantastic!

alfredoeleazarorozcoquesad
Автор

Nice Man, just starting out in game dev looked at things people teaching now
and yet ur are awsome

symbiotescorns
Автор

Excelent videos, you're the best game programmer in youtube :D

TheJuancar
Автор

Very nice tutorials, just blasted through the first 11 and decided to throw you some likes. Which is something I rarely ever do on youtube. Cheers man.

Trophus
Автор

I wish i could give you more than 1 like dude!

But I skipped ahead and it looks like the series ends at #17 without fully finishing the project? (or is the idea just to get us started)

samdeacon
Автор

In case this helps anyone: I kept getting a nullpointer error on this if statement inside the LoadImageLevel method:
 if (red ==255 && green == 255 & blue == 255){
                 handler.addObject(new Block(xx*32, yy*32, ObjectIdentity.Block));
                 System.out.println("block: ");
             }

The problem was simple to fix - in the int method, make sure your call to LoadImageLevel(); happens AFTER you initialize handler(); ( handler = new Handler();)

The nullpointer error happened because handler was not yet initialized and LoadImageLevel was trying to refer to it. So @ 7:40 when Tuts say, "No... put it up here", listen to him otherwise you'll get the same error I struggled with for 20 minutes XD

Anyways, awesome design to create levels using paint!!!

gilbertsalcedo
Автор

For those still getting the null exception error try either of the following:
1.
In the BufferedImage class change:
image =
to
image =

& in the Game class change:
level =
to
level =

2.
Check that the 'res' folder was declared properly. On the Java Build Path screen under the Libraries tab, after setting the Add Class Folder path you should have the following:
Modulepath
JRE System Library [JavaSE-11]
Classpath
*FileName*/res(class folder)

If you're getting the error you likely instead have this:
Modulepath
JRE System Library [JavaSE-11]
*FileName*/res(class folder)
Classpath

Thus, you will need to drag your file from the Modulepath to the Classpath as the former is looking inside the latter to find the file that isn't actually there.

odolwa
Автор

most epic shit i've ever seen
this is some valhalla nirvana extasy for me, thanks for showing <3

Gottii
Автор

I would love if you showed how to do something like this in unity.

shatley
Автор

nice tutorial with a good twist at the end :P

ttse
Автор

For anyone interested, I did the loadImageLevel a bit differently. Instead of dealing with the bitwise operations and numeric comparisons, I did this:
int pixel = image.getRGB(xx, yy);
Color pixelColor = new Color(pixel);

if
{ ...

Seems far more readable to me. Hopefully this helps!

justinwahlquist
Автор

also anyone using gimp, after you file, export to your res folder. make sure you right click your project and refresh, even after every update to your level.png drawing. if that doesn't work click project clean from the top menu bar. that helps when importing stuff into your project. Hope these posts help someone.

jasonzimmerman