Lighting Item - How to Make a 2D Game in Java #45

In this video, we add a lantern so we can equip/unequip it and change the lighting situation.
Guidelines for using Blue Boy Adventure's code and assets:
docs.google.com/document/d/1q...
Timestamps:
0:00 Introduction
0:45 Code Update
2:30 Creating Lantern class
5:48 Equip/Unequip the lantern
9:10 Switching lighting On/Off
15:00 FINAL RESULT
#gamedev #2DactionRPG #tutorial

Пікірлер: 43

  • @jaymakay
    @jaymakay Жыл бұрын

    Ryiiiiiiiiiiiiii!! Finally, a notification worthy enough to click! haha Welcome back, Ryi 👍

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    Thanks! I'm glad to be back :)

  • @Mohd_Zaid_khan
    @Mohd_Zaid_khan Жыл бұрын

    i am currently learning java, so i have kept this playlist saved whenever I'll be done I'll start gamedev. thanks alot for the work you're doing, i have to say, this playlist is pretty rare to find. indeed a gem

  • @moonpaper215
    @moonpaper215 Жыл бұрын

    Just wanted to tell you: this is an amazing series that has helped me a lot. I'm happy to see you back :)

  • @trikkinikki970
    @trikkinikki970 Жыл бұрын

    Hey welcome back, buddy. Thank you for sharing your journey in learning coding with us. I need to get my IDEs all set up on my new computer than I'll actually start giving your tutorials a thorough go.

  • @kabbiecabbs4320
    @kabbiecabbs4320 Жыл бұрын

    ive been learning so much bro thank u :)

  • @jeff_u_tube1028
    @jeff_u_tube1028 Жыл бұрын

    Yay hes backkkk :D I finished the other videos yesterday haha

  • @TORMENTUMM
    @TORMENTUMM9 ай бұрын

    Another great video

  • @Mrtargi
    @Mrtargi Жыл бұрын

    Wow! I can't even imagine what I would do without your tips! Thank you so much! I know that you finished yor project but maybe you can share some tips like how you're placed torches in previous video? Or iher environment conditions like rain or fog?

  • @MrLoser-ks2xn
    @MrLoser-ks2xn Жыл бұрын

    Thanks!

  • @darkpaladin.
    @darkpaladin. Жыл бұрын

    Amazing video my friend

  • @kevincolgan6651
    @kevincolgan6651 Жыл бұрын

    This is great Thanks

  • @robertpatrickson3906
    @robertpatrickson3906 Жыл бұрын

    YES you are back!

  • @momagi6039
    @momagi6039 Жыл бұрын

    NICE!

  • @Serious_Im
    @Serious_Im Жыл бұрын

    Yay new video

  • @AlooMood
    @AlooMood Жыл бұрын

    Hi Ryi, the series you made is beyond perfect. I wonder if you would consider making a 3d game in java after this series.

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    I think my next project will also be 2D since I like 2D games better. Not that I'm not interested in 3D though!

  • @josesanp
    @josesanp Жыл бұрын

    nice!!!

  • @kpm25
    @kpm25 Жыл бұрын

    @RyiSnow.... I have totally caught up on your tutorials now thanks for uploading lesson #45. Also, I was interested to make a 2d_TileEditor similar to how you made yours. Do you have any you could recommend me to try in the meantime that converts to the same .txt format that you use?? Much appreciated.

  • @IzmoRL

    @IzmoRL

    Жыл бұрын

    yes please i need it too.

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    Tiled probably be the best alternative. I've been thinking to prepare a simple tile editor for this series but haven't really got time to finish it...

  • @kpm25

    @kpm25

    Жыл бұрын

    @@RyiSnow Thanks! I appreciate your effort especially when you have other work to do.

  • @paul7408

    @paul7408

    Жыл бұрын

    I use tiled and once you get the hang of it its great

  • @kpm25

    @kpm25

    Жыл бұрын

    @@paul7408 Yep, you are right, I've been using it for a couple of days and its all you need once you get used to it. Maybe RyiSnow might be interested in doing a tutorial on how to import .tmx files into his game that use mulitiple layers.

  • @HamoodiHajjiri
    @HamoodiHajjiri Жыл бұрын

    Afternoon, RyiSnow. Great day, I appreciate all the videos you're making, you officially made me start with my Java Journey. Gotta ask you a favor if you could implement on a video, one day, you know how we have dialogues? I'd like to ask if the height of the dialogue screen could depend on how many lines of texts there are in the dialogue screen, itself? It'd be much appreciated. Also, optional. We could do some sort of pagination or similar idea in the dialogues?

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    Here's an example of an adjustable dialogue window: public void drawDialogueScreen() { // WINDOW int x = gp.tileSize*3; int startY = gp.tileSize/2; int y = startY; for(String line : currentDialogue.split(" ")) { y += 40; } int width = gp.screenWidth - (gp.tileSize*6); int height = y + 40 - startY; drawSubWindow(gp.tileSize*3, gp.tileSize/2, width, height); y = startY; g2.setFont(g2.getFont().deriveFont(Font.PLAIN,32F)); x += gp.tileSize; y += gp.tileSize; for(String line : currentDialogue.split(" ")) { g2.drawString(line, x, y); y += 40; } }

  • @HamoodiHajjiri

    @HamoodiHajjiri

    Жыл бұрын

    @@RyiSnow Fair enough, however, we're adjusting the size of the window depending on the number we input, correct? Can't the dialogue window be adjusted *depending on how many lines there are*, automatically? I mean, thinking twice about this, I believe I can just modify the height of the dialogue depending on how many " " there are, correct?

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    >we're adjusting the size of the window depending on the number we input, correct? No. >I can just modify the height of the dialogue depending on how many " " there are, correct? That's what the example code is doing.

  • @romawar1869
    @romawar1869 Жыл бұрын

    I love this game

  • @dungtuan9561
    @dungtuan9561 Жыл бұрын

    hey bro, I thought that you won't make video, I am a huge fan of you from VietNam, I have learned a lot from your 2D game series

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    Glad to hear that. Actually, I announced that I would be away from the channel for a while in the community tab.

  • @kamisama1712
    @kamisama1712 Жыл бұрын

    cant believe i'm almost caught up

  • @malikarslan2672
    @malikarslan2672 Жыл бұрын

    Will we see soon how to use the load game from the title Screen?

  • @MrLoser-ks2xn
    @MrLoser-ks2xn7 ай бұрын

    🥰🥰🥰

  • @kapa9436
    @kapa9436 Жыл бұрын

    Hi ! I was looking to add a feature but for that i need to detect wich tile is under the player,how can i do that ? Thanks in advance

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    You can get it with the following code: int playerTileNum = tileM.mapTileNum[currentMap][player.getCol()][player.getRow()];

  • @anonymous-3695
    @anonymous-3695 Жыл бұрын

    I turned this light into a colored light. thought i might share the code, this one makes a orange light on which for me simulates a nice torch or campfire etc better. much more cosy.hope it helps someone. Color color2[] = new Color[2]; float fraction2[] = new float[2]; float fR = 253 / 255.0F; float fG = 120 / 255.0F; float fB = 9 / 255.0F; color2[0] = new Color(fR,fG,fB,.50f); color2[1] = new Color(fR,fG,fB,.20f); fraction2[0] = 0.10f; fraction2[1] = 1f; RadialGradientPaint gPaint2 = new RadialGradientPaint(centerX,centerY,(float) (circleSize / 1.5),fraction2,color2); g2.setPaint(gPaint2); g2.fill(lightArea2); this is BEFORE your regular light code. THEN the outside darker circle Color color[] = new Color[5]; float fraction[] = new float[5]; color[0] = new Color(0,0,0,0f); color[1] = new Color(0,0,0,0.25f); color[2] = new Color(0,0,0,0.5f); color[3] = new Color(0,0,0,0.75f); color[4] = new Color(0,0,0,0.95f); fraction[0] = 0f; fraction[1] = 0.25f; fraction[2] = 0.5f; fraction[3] = 0.75f; fraction[4] = 1f; RadialGradientPaint gPaint = new RadialGradientPaint(centerX,centerY,(circleSize / 2),fraction,color); g2.setPaint(gPaint); g2.fill(lightArea);

  • @michaelharrington5860
    @michaelharrington58609 ай бұрын

    Encountering a bug with my lighting. When I quit the game and go back to the title screen state, upon starting a new game, everything is reset, but the lantern lighting doesn't reset despite no longer having a lantern equipped in my inventory. Any idea what might be the cause?

  • @RyiSnow

    @RyiSnow

    9 ай бұрын

    I think some stats still don't get reset properly when you restart the game at this point... I fixed them in later episodes though. Sorry about that! For the lighting, basically there are two elements that define the lighting status: currentLight and lightUpdated These two booleans should be set as currentLight = null and lightUpdated = true at the start of the game. Then the lighting will disappear!

  • @michaelharrington5860

    @michaelharrington5860

    9 ай бұрын

    @@RyiSnow Thank you for the speedy response. I did what you said and reset those two boolean values (in the setDefaultValues method of Player class) and it fixed the issue. On to the next video!!

  • @endercode1164
    @endercode1164 Жыл бұрын

    POGGIES

  • @HamoodiHajjiri
    @HamoodiHajjiri Жыл бұрын

    You should make a video implementing tags. Example, having a tag above each player's or NPC's name like "RyiSnow" or "Old Man". Moreover, above the tag, if you'd like to talk to the user, you can do something like "if user presses E while radius between user and NPC is 1 tile, then talk to NPC". Would that be possible? 👀 With that, above the tag, you can mention "Press E to talk". It's like in Roblox, as an example.

  • @accumulator4825
    @accumulator4825 Жыл бұрын

    2nd!!