Projectiles - How to Make a 2D Game in Java #29

  Рет қаралды 18,235

RyiSnow

RyiSnow

Күн бұрын

Пікірлер: 102
@kikismine
@kikismine 2 жыл бұрын
Oh my good new tutorial RyiSnow is not dead!!
@RyiSnow
@RyiSnow 2 жыл бұрын
I'm not lol
@woodswoody5553
@woodswoody5553 2 жыл бұрын
Yes ryi snow! I love your tutorials! I have learned so much and added a coin system for trading with npcs for items just from watching ur tutorials I have built so much more than I could ever think. Sending positivity ur way. I also made a key door thing so they could be used to open doors and chests in the game. I would have never believed I could do this months ago! Thank you!
@RyiSnow
@RyiSnow 2 жыл бұрын
That's great to hear! Keep it up!
@Mypremiumacct
@Mypremiumacct 2 ай бұрын
loved this tutorial. Been finishing before bed after work and has been a great way to unwind and learn something new
@zurielnovelo9291
@zurielnovelo9291 2 жыл бұрын
I recently found your tutorials. I really like them because its so easy to understand and I have always wanted to make a game.
@FerodriEste
@FerodriEste 2 жыл бұрын
60 days waiting for this day!! I didn't leave my house waiting for this day, I didn't eat, I didn't sleep. Thank you for coming back!!😆😆
@Wernix228
@Wernix228 2 жыл бұрын
Hi, your lessons are very useful and understandable, please do not abandon this case
@douglassparks6050
@douglassparks6050 2 жыл бұрын
I am really enjoying following along with your tutorial. Keep up the great work! Your tutorial has helped me understand Java and programming so much more. I really appreciate the time you have put into creating an easy to follow and detailed video series. You've helped me fall in love with programming all over again. Thanks!
@RyiSnow
@RyiSnow 2 жыл бұрын
Great to hear that! Thank you for the comment.
@LeighFlies
@LeighFlies 2 жыл бұрын
@@RyiSnow Hi Ryisnow, would you be able to provide any information on how to remove the item from the inventory when it is thrown? We use itemIndex when using consumables, but this relies on the slot being selected and in the character gamestate. In my case, i am allowing the user to pick up a dogs bone and throw it just once, and then setting a new instance of it to be collectable when 'alive' reaches false, so it can be repeated. Therefore this means the process must occur when the inventory is closed and the game is in playState, by directly interacting with the ArrayList, but I don't know the best way. My current system of removing it from the inventory is a bit thrown together and can cause errors with out of bounds errors on the array, if another item is used and removed from the inventory such as a consumable, while the bone is in possession. Thanks in advance.
@laurenzfitzner
@laurenzfitzner 2 жыл бұрын
Thank you for going through this topic! I'm especially looking forward to the next video when NPCs can shoot projectiles too! Ps. It's really cool to see your own comment in a KZbin video not gonna lie! XD
@RyiSnow
@RyiSnow 2 жыл бұрын
Glad you liked it :D
@Locras
@Locras 2 жыл бұрын
You're alive, great. The video is perfect.
@Gius_Valentine
@Gius_Valentine Жыл бұрын
i did something a bit different for damage calcs and the cooldown problem I wanted to create an animation for the player shooting magics, so I created a method similar to the attack one, and called it everytime the magic was used, booting with personalised startup/endlag the damage i created another method, and called it when the damage came from a projectile instead of the player, so magics and weapons could have different effects effects like, phys atacks restore mana and calculate off of different stats
@elvispontes4165
@elvispontes4165 2 жыл бұрын
Thanks a lot again for your tutorials... they are the best as aways!!!
@PixelVearn
@PixelVearn Жыл бұрын
thx for that great tutorial plz can u tell us how to do animation for player when he cast projectile
@Denis-cz5ys
@Denis-cz5ys 2 жыл бұрын
Hey man thanks for the video but where have you done the draw methode for the fireball cuz i can cant find it .
@RyiSnow
@RyiSnow 2 жыл бұрын
It's in the Entity class. The Projectile is a subclass of it.
@dadwhogames1-m3g
@dadwhogames1-m3g Ай бұрын
How would I make it so that the projectile does not read player as a target so that we can shoot the fireball while walking?
@OneLatteComingRightUp
@OneLatteComingRightUp 5 ай бұрын
Hi ryisnow!! I created a method to shoot multiple projectiles at once from a use() method with an interval using thread.sleep() but it stops the entire program. Is there another way that I can create a multishot projectile that shoots 3 in the same direction at different times?
@FriskTheFallen
@FriskTheFallen Жыл бұрын
I fixed that issue with the monster damage after death while watching the episode on implementing that part of the combat and left my solution posted there.
@Merkuse
@Merkuse 2 жыл бұрын
Hello RyiSnow, I really enjoy your tutorials and I got a question: How to disable the monster collision when there is a death animation ? So, if animation is pretty long you don't have to wait for the end of animation to pass if the monster was standing in your way And how to disable the monster collision when the character is invincible. Thus, if the monsters push the character into a corner, he will be able to escape when he receives damage. Also thanks for your videos !!!
@RyiSnow
@RyiSnow 2 жыл бұрын
Set conditions for cChecker.checkEntity such as invincible != true, dying != true etc. Collision won't happen as long as you don't call that method.
@Merkuse
@Merkuse 2 жыл бұрын
@@RyiSnow Thank you ! Also thank you for very fast very quick response!
@Merkuse
@Merkuse 2 жыл бұрын
For others: do that in Java class Player, update method under "//CHECK MONSTER COLLISION"
@istand4myself
@istand4myself 2 жыл бұрын
At 13:11 I don't quite get it... Why are you passing player's worldX and worldY when you should pass his screenX and screenY, since screenX and screenY are the coordinates of the middle of the screen where the player is always drawn (besides when player is at the map edges)?
@RyiSnow
@RyiSnow 2 жыл бұрын
Because projectiles are entities and entities are drawn based on their worldX and worldY. Try passing screenX and screenY then you know what I mean.
@istand4myself
@istand4myself 2 жыл бұрын
@@RyiSnow thx. I was just implementing my custom projectile mechanics for player. I have implemented mousehandler that is I can press LMB anywhere on the screen and the projectile follows that direction. It was a bit of struggle drawing it though
@dontouchlollo2382
@dontouchlollo2382 2 жыл бұрын
Can you make a video on how convert your movement system of the player with 4 directions to 8 and also the collision with 8 directions? Pls
@ganbarimasu9446
@ganbarimasu9446 2 жыл бұрын
if you add "if(W_pressed == true && D_pressed == true) in keys part, this will work for going north east. While doing that you would need to implement new images and player.worldx += 2; player.worldy += 2; It's roughly something like that. I explained without much detail hoping you would understand, but if you have a point you don't understand, feel free to ask :)
@dontouchlollo2382
@dontouchlollo2382 2 жыл бұрын
@@ganbarimasu9446 yes but the collision don't work with 8 directions
@ganbarimasu9446
@ganbarimasu9446 2 жыл бұрын
@@dontouchlollo2382 I think it wouldn't be a problem since collision checker and movements are not directly relates. Even if you go diagonally, collision checker would still do its job and stop you if it's necessary. To avoid facing more problems, you may shorten the sides of the player collision rectangle.
@dontouchlollo2382
@dontouchlollo2382 2 жыл бұрын
@@ganbarimasu9446 the problem is that when the player moves diagonally and hits an obstacle he gets stuck, I don't how can I resolve it.
@ganbarimasu9446
@ganbarimasu9446 2 жыл бұрын
@@dontouchlollo2382 by stuck do you mean it stops moving completely after touching an obstacle? Or, it just collides with obstacles while trying to change it's location.
@hoobastankfan8884
@hoobastankfan8884 2 жыл бұрын
Hey RyiSnow, thank you so much for these excellent tutorials! I have a question, because I'm trying to add some stuff to your base game as a fun challenge. For instance, I'm wanting to create the ability for the player to not only shoot projectiles (which you already implemented), but to set mines on the ground. In what class would I get the values to set the coordinates for my mines so that I can put them into a mines ArrayList to be drawn in the GamePanel class? I have created another method inside of Player called setMinePointIfKeyPressed() which is similar to fireProjectileIfKeyPressed(), and successfully adds the mines to the ArrayList, but it is not able to draw the mines when the F key is pressed in the Entity draw() method.
@Mrtargi
@Mrtargi 2 жыл бұрын
Hello Ryi! How can I turn off projectiles while I'am interacting with surroundings? I am using range weapons like other weapon, not extra and using the same key, I wrote all the conditions, but every time when ranged weapon choosed and i try to interact with smth, it shooting😬
@solarcubing7504
@solarcubing7504 2 жыл бұрын
Hey Ryi could u make a tutorial on map doors and stairs to transfer between maps and stuff like that
@paul7408
@paul7408 2 жыл бұрын
yes plz
@RyiSnow
@RyiSnow 2 жыл бұрын
We'll handle that when we create a dungeon level.
@rainbowpainting7090
@rainbowpainting7090 2 жыл бұрын
For some reason the collision of the fireball is not being detected, i cannot see why it isn't working. please help!
@kimabramesteban3017
@kimabramesteban3017 Жыл бұрын
What do you think is my problem? The code is working but the Fireball image isn't displayed.. I said the code is working because the location of the fireball is working. I put System.out.println there with the location of the Fireball. The problem is just the Fireball is not showing up but the names of the file are correct. There are no errors there.
@kimabramesteban3017
@kimabramesteban3017 Жыл бұрын
I'm thinking of this, I can't see how the image from OBJ_Fireball was used when pressing F and when the ShotPressed is true.
@rexroyulada6267
@rexroyulada6267 9 ай бұрын
I'm having the same issue, the image isn't being shown despite the file path being read
@rexroyulada6267
@rexroyulada6267 9 ай бұрын
@@kimabramesteban3017 Nevermind, check you boolean for the fireball object. remember to add "this.alive = alive"
@abohoney
@abohoney 8 ай бұрын
@@rexroyulada6267 Did you know why?
@abohoney
@abohoney 8 ай бұрын
Did you know why?
@xm0r1t2x8
@xm0r1t2x8 2 жыл бұрын
Is there a way to make the window fullscreen, without any issues
@VasiliyNikitin
@VasiliyNikitin Жыл бұрын
There is no link to the following video at the end of this video. Thx 4 lesson
@RyiSnow
@RyiSnow Жыл бұрын
Thank you for letting me know. Just fixed it!
@BrimstoneMwG
@BrimstoneMwG Жыл бұрын
Hello! I know it's a pretty late post so I may not get a response, but I removed the restriction of only being allowed to have one fireball alive at a time, and now if I fire a second fireball while the first is alive, the second moves twice(or possibly exponentially) faster. I would normally assume this was because the speed variable is being increased but not reset, but I can't find anywhere that the speed actually gets adjusted, so instead I am now guessing that maybe it is updating twice as often because there are two entities out at the same time. Shouldn't they both be separate from one another? I have lots of ways to work around it, so I am not concerned, I am just curious what may be causing it because I assume at some point in the future I will probably want multiple projectile out at once. If anyone happens across this and has any advice please share! Otherwise, I'm gonna keep trucking along through these wonderful tutorials!
@narlock
@narlock Жыл бұрын
Hi, I suspect this is happening because the player projectile is the same "Fireball" instance (not 100% sure though didn't look too much into it) What I did to accomplish this was to first set projectile to a new Fireball when the shot key is pressed. If you do this and remove the alive logic, you may notice that a million different projectiles will appear on your screen. To fix this, we can add a counter similar to how RyiSnow has implemented all of the other counters in the course. Once you do that, you can fire a projectile after x amount of frames that pass, and you can have multiple projectiles on the screen that come from the player. Not sure if this was addressed in future episode since I am following them in order. Hope this helps.
@Moordiin
@Moordiin 2 жыл бұрын
You are back lets gooo!!!
@LKPablo678
@LKPablo678 8 ай бұрын
Wouldnt be easier to just do a cooldown?
@MCStarYT
@MCStarYT 2 жыл бұрын
Are there any more tutorials episodes on the game coming in the future or this is the final one?
@RyiSnow
@RyiSnow 2 жыл бұрын
28:20
@garrison4825
@garrison4825 2 жыл бұрын
Hey Ryi two questions. First, are you planning on making an RPG side scroll game tutorial? And Second do you have any plans releasing your games in itch.io?
@RyiSnow
@RyiSnow 2 жыл бұрын
I still don't know what I will make next. I'm interested in developing side scroller and sandbox game but since the current one has been quite a work I want to do something smaller next. Something different from this one for sure. I've been developing a dungeon crawler RPG for a while and I'm aiming to upload it on itch!
@vampsz1592
@vampsz1592 2 жыл бұрын
Hello, I got a question: I made a dagger with a poison effect so the monster that was hit gets a little bit damage every 3 seconds and this 3 times. But if I hit another monster the "focus" of the poison effects switches to the other monster, bc I used the index from the attacking (or damage method? I don't know right now) method. Is there any thing I can do, to poison every monster I hit?? Also thank you for your tutorials, I learned so much watching them!!
@RyiSnow
@RyiSnow 2 жыл бұрын
Here's an example: You can create a poison status boolean in the Entity class so you can keep the poison status on each monster. When you hit a monster with the dagger, set the monster's poison status true. You can reduce the monster's life at certain interval in its update method.
@vampsz1592
@vampsz1592 2 жыл бұрын
@@RyiSnow Ill try it, thanks alot!!!
@havardelgsaas2603
@havardelgsaas2603 2 жыл бұрын
When I pick up an object(item), the text shows: "You got a Green Slime". Does anyone know how to fix this problem? I wrote: text = "Got a " + gp.obj[i].name + "!"; in the Player class. And when did you add user in Entity?
@havardelgsaas2603
@havardelgsaas2603 2 жыл бұрын
public String name was static. But I still wonder... When did you add "user" in Entity? Is it possible to add a string called public Entity user in Entity without doing anything else?
@woodswoody5553
@woodswoody5553 2 жыл бұрын
Is there any way to toggle inverse colors? For example binding the "i" key and when iPressed = true then all the tiles, monsters, objects and character inverts color. I put a filter over my game and it looks amazing. Ryi snow or anyone if you know I would greatly appreciate it or if you could point me in the right direction I could probably find a way to do it. Thank you!
@bandicamnick7903
@bandicamnick7903 2 жыл бұрын
Welcome back!
@alphabeta3528
@alphabeta3528 Ай бұрын
thanks for the video
@TerminallyUnique95
@TerminallyUnique95 2 жыл бұрын
What if I want some projectiles to be different than tile size. Do I need a new draw method?
@RyiSnow
@RyiSnow 2 жыл бұрын
Not necessary. If you have scaled the image when you imported them, you just can draw them as they are. ...Having said that, I just realized that I forgot to remove gp.tileSize that specifies its width and height from the g2.drawImage in the Entity class. I guess this is why you thought it cannot draw non-tile size images. We don't really need to set width and height in the drawImage method any more so remove them then it draws images with their scaled size. I'll update the code later!
@RyiSnow
@RyiSnow 2 жыл бұрын
Think about the Player class's drawImage. We're drawing images with different sizes for attacking animation.
@knightking5735
@knightking5735 Жыл бұрын
Does anyone knows how to fix this bug? So basically when i start the game, i can shoot projectiles but the thing is that i need to move whenever i need to shoot a projectile for example i need to move , if i stay still and if i pressed F, it doesnt work, do u know how to fix it RyiSnow?
@eruption678
@eruption678 2 ай бұрын
hello i know this is a year late, but it's possible that the direction of your player is being reset whenever you stop moving which causes the projectile to not have a direction when shot
@justsomedude8324
@justsomedude8324 2 жыл бұрын
I used an array instead of a list for storing projectiles, is there an advantage to using a list, if you don't have to sort it?
@RyiSnow
@RyiSnow 2 жыл бұрын
I think normal array is fine too. I wasn't sure how many objects will be displayed on the screen at the same time so I used array list (also you need to search a blank slot whenever you create a new projectile and that is a bit of pain)
@justsomedude8324
@justsomedude8324 2 жыл бұрын
@@RyiSnow It was mostly my OCD, seeing three arrays for ingame objects and one list, bugged me to fits. ^_^
@RyiSnow
@RyiSnow 2 жыл бұрын
No worries. Maybe I should have used ArrayList for other entities too.. sorry for the confusion!
@coolcool2053
@coolcool2053 2 жыл бұрын
Hi ryi when i am walking i cant shoot but only when i am stand, do you know why?
@RyiSnow
@RyiSnow 2 жыл бұрын
Maybe you added "else" to the if statement?
@coolcool2053
@coolcool2053 2 жыл бұрын
@@RyiSnow to which if statement you mean?
@knightking5735
@knightking5735 Жыл бұрын
@@coolcool2053 this happened to me, its very very easy to fix, just remove this code from the else statement and put it out of the else statement: if (gp.keyH.shotKeyPressed == true && projectile.alive == false && shotAvailableCounter == 60) { // SET DEFAULT COORDINATES, DIRECTION AND USER projectile.set(worldX, worldY, direction, true, this); // ADD IT TO THE LIST gp.projectileList.add(projectile); shotAvailableCounter = 0; gp.playSE(10); }
@sketchbyk.v.s
@sketchbyk.v.s 2 жыл бұрын
Bro please help me out🙏🙏🙏🙏🙏I am able to shoot my fireball but it stays at the same place it doesn't go forward, it just stays there Can anyone help me with this🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
@BrimstoneMwG
@BrimstoneMwG Жыл бұрын
I had a similar problem and it was because I accidently overloaded my Projectile.update() inside of my OBJ_Fireball class. Make sure you do not have an update() method in your OBJ_Fireball class, even if that method is left empty.
@coolcool2053
@coolcool2053 2 жыл бұрын
Hey ryisnow where is the Draw method?
@RyiSnow
@RyiSnow 2 жыл бұрын
In the Entity
@UnderArea51
@UnderArea51 2 жыл бұрын
What are "A Star" moments?
@RyiSnow
@RyiSnow 2 жыл бұрын
What do you mean?
@romawar1869
@romawar1869 2 жыл бұрын
thank you RyiSnow
@MrLoser-ks2xn
@MrLoser-ks2xn 2 жыл бұрын
Thanks!
@MrLoser-ks2xn
@MrLoser-ks2xn Жыл бұрын
🥰🥰🥰
@paul7408
@paul7408 2 жыл бұрын
YAY
@desertfalcon3645
@desertfalcon3645 2 жыл бұрын
i would need a little bit of help, can i add you on ds?
Knockback  - How to Make a 2D Game in Java #41
18:37
RyiSnow
Рет қаралды 7 М.
$1 vs $500,000 Plane Ticket!
12:20
MrBeast
Рет қаралды 122 МЛН
I Sent a Subscriber to Disneyland
0:27
MrBeast
Рет қаралды 104 МЛН
How to Code (almost) Any Feature
9:48
DaFluffyPotato
Рет қаралды 715 М.
Stackable Items - How to Make a 2D Game in Java #43
18:38
RyiSnow
Рет қаралды 5 М.
Transition Between Maps - How to Make a 2D Game in Java #38
34:59
I Beat Minecraft From One Grass Block
35:27
Beppo
Рет қаралды 7 МЛН
A.I. Learns to play Flappy Bird
7:46
Code Bullet
Рет қаралды 14 МЛН
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,4 МЛН
Coding Adventure: Chess
29:22
Sebastian Lague
Рет қаралды 3,8 МЛН
Equip & Use Items - How to Make a 2D Game in Java #28
27:53
Guard and Parry - How to Make a 2D Game in Java #49
26:08
RyiSnow
Рет қаралды 6 М.