I've now completed everything up to this tutorial. I didn't expect to be so invested in this series, but I feel like I'm learning so much everyday. My wife had to pull me away from the computer the past few nights because time simply flies while following along with your explanations. You are so knowledgeable of Java. Do you develop games for a living? It's nice being able to code a game and brush up on my Java at the same time. Mostly use Typescript these days aside from Java Spring on the backend. Thanks again!!
If you have the issue I did, that you get to around 15:45 and you cannot talk to the NPC through the table, make sure the NPC has not moved. My table was not stopping the NPC from changing position and he walked 2 tiles south before bumping into the table and I could not talk to him. I moved the table one tile south of his start position so he did not move, and it worked.
Your game is getting better and better, in your next episode could make a menu of key configuration (a new tab of the menu option for example). good day
It's great to see you back with another master class :D I was thinking that would be interesting you could compare the items you're buying with the ones you have equipped, so you could see if those improve or decrease your stats. The other thing i was wondering is that as it is now, you could sell the things you have equipped, right? So when you sell your shield it automatically unequips itself from your inventory? Thanks as always, sensei
You cannot sell equipped item as we handled so in this video. The weapon/shield comparison is a good idea. That said it's not difficult to implement it. You just need to display the attack/defense value of your current equipment and also the currently selected item. Try creating a sub window and display the value in it.
@@RyiSnow I did this but it only shows the value of the CurrentWeapon = new OBJ_Normal_Sword(gp) in the player class. I cannot for the life of me get it to show the current weapons description. Also, this is for comparing what I have in my inventory to what I have equipped. I understand what you're saying about the subwindow with the traders inventory.
is there a shortcut to close/compress all the sections inside one class? I've seen how sometimes all the sections you have are closed and that makes it easier to find things
Hi, I have a problem when executing the drawInventory() method. When choosing trade_buy() in the game, an error appears in the console that entity is null. When checking through the debugger, I got to the point that the Entity npc variable in the UI class is null. How to fix it?
i need help about something.When i change map i located a npc.At located position i can talk with npc but npc was located 6 col away throught right.I can talk with a blank space and when i move, npc is moving oppositely with whenever i press keys.It s like a visual bug.Blank space is holding and not moving as i want and i can talk to him.
Hi there, i want to let the NPC stand still at one place, but whenever i move close to NPC, it moves in the opposite direction as me. Can somebody help me fix this :(
Just in case anyone was having this problem, the player's items were not showing (but they obviously existed and were there, since I could use a red potion even if the image wasn't showing) this is the solution: Both the Entity class and the Player's class had this line: public ArrayList inventory = new ArrayList(); it will cancel if it's in both classes, since the player extends Entity I figured it out because the NPC didn't have that class and that one was working fine Just delete that line from the player's class and you're good to go
I've been having an issue for a while now and can't seem to fix it. When interacting with an NPC, the dialogue gets drawn inside the dialogue box once, but it also gets drawn a second time outside the text box. This happens for every dialogue box though, so for the trading windows my screen is just covered in multiple instances of the same text. I can't seem to figure out where I've gone wrong with it, any help would be greatly appreciated. As far as I know i've followed th code almost identically, but guessing there is an issue with one of my methods such as 'addMessage', 'drawMessage' 'drawDialogueScreen', 'speak'. Or it could be something to do with setting the state somewhere. If anyone has faced this issue or can help i'd be extremely grateful, thanks
I have been learning a lot from these videos. I was wondering if you could make one with a form of “questing” system or if that would not be a part of this course
Hey again! I have this problem where when you enter map 2 to meet the merchant, it takes a few seconds for it to appear. What could be the cause of this? Any particular place that comes to mind if this happens? The old man NPC also takes some time to appear now. Thanks!
Hi, please help me. I am trying to create a way of knowing if an item is in the players inventory. I want to require a key to be in the inventory in order to use it but i can't figure out a way to make an if statement like inventory.contain(OBJ_Key); but that doesn't seem to work. If you could help me out I would greatly appreciate it.
Uhm im having this really weird problem where only the merchant's item's get drawn. I can select items from the players inventory and use them aswell but they don't show up as sprite so i cant see the items. I would really appreciate some help thx.
Hello Ryi I have question about how works NPC in that program. To be accurate I am wondering about that part in NPC construct: solidArea = new Rectangle(); solidArea.x = 8; solidArea.y = 16; solidAreaDefaultX = solidArea.x; solidAreaDefaultY = solidArea.y; solidArea.width = 32; solidArea.height = 32; What it does ? Also if I delete this part then Merchant starts moving after talking with him in player's opposite direction. But if I delete this part in Old_Man then nothing changes. Also I do not remember writing it in part#14
@@RyiSnow Oh yeah just figured that out. Been here since tutorial 1! Really learned alot and have tailored alot of things sfter learning from you how to implement my ideas. THANK YOU RYI SNOW!
Can you please help us create and implement a countdown timer function? Like let s pretend we have in the right corner of the game screen a timer with 3 minutes left and if you don't do a task in these 3 minutes the level restarts or something. Thank you for everything you ve done!
So when you're making this. Are you skilled enough on your programming skills that you're making it the most efficient way? Like is this the best way to make this game from scratch? Or when you are editing do you see you can make better tweaks to your code? I'm still new to coding I'm sure curious. Good Job! Anyways
Only thing I can say is you never know what the "most efficient/best way" in coding. Even if you are the most talented programmer in the world, you might come up with a better way tomorrow, to handle what you wrote yesterday. There is no absolute way in coding and everyone has their own style.
im 16 minutes in and I dont get a dialogue screen when i try to speak from across the table, i just get frozen game with no error, made me think of another way to handle merchants behind counters... EDIT: figured out my issue. I did not have 'i=0;" under 'mapNum = 1;' in AssetSetter different merchant idea Make the table the merchant, so you are actually interacting with the table and the merchant npc is more so a dummy. If you have a merchant thats not behind a table you could just have the merchant interact as you do now. Maybe making the table have a little cash register and if you speak to a merchant thats behind a counter the just say something like "please speak with me at the register to purchase or sell any items" i have a large request too , any chance you could add a slot machine ? I want to make a casino similar to the ones in original Pokemon. Now that we have NPC we could use that to exchange for 'casino chips' and have another one with prizes. Im thinking the slot machine would work alot like the enemy drops. Would need some basic slot reel images also like cherries, 7s, BAR sign, etc. You could have a losing spin display a variety of losses ( ie 7 Cherry Bar or like Bar Cherry Cherry) , and then winners display like " 7 7 7 or Cherry Cherry Cherry" and gives player chips
Sorry but slot machine is more like a flavor mechanic and it's a bit out of theme of this tutorial. I need to take care of fundamental mechanics first otherwise this series will never reach the end! Handling the table itself as NPC is actually an interesting idea but the problem is you can talk to it from left and right side too and that would be a bit strange since player is not facing the actual NPC that way. Still it can be a hint to solve this issue so thanks for the suggestion.
@@RyiSnow thanks for the reply! Slot machine defiantly a flavor mechanic, and totally get how it could be never ending series (we all low key want this series to never end lol) I think ill create a vending machine to use later, cause i figured out what my issue was that led me to thinking of the npc table merchant idea. Also, what is your next plan for a series? I am so interested in whatever it will be.
Hi sir, I have watched all your videos in this playlist and they really are helpful to me who is a slow learner in programming. One problem I am facing is that when I try to go to location( worldX - 888, worldY - 1916 OR worldX - 724, worldY - 1560 or somewhere under that area), the program stops and show several run-time errors (BTW I am using netbeans 8.1) and one of them is " Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException " "at tile.TileManager.draw(TileManager.java:114) ". I hope u find my problem solution. Thank you very much.
@@RyiSnow But it is strange that it only happens in worldV3 but not in worldV2 or in any other maps . Btw could u place a pixel house on right top of the map where the player first appears?
@@RyiSnow Damn!!! It is my DUMB mistake!!! When I test to place an trunk on the map, I instantiated and placed on the .txt file but I totally forgot to change the tile number 42 to 41 after deleting the instance. LOL!!! So sorry for wasting ur time! And thank you very much for your help.
Everything is working great however there is one small bug. You can buy and sell items fine but if you buy something like equipment multiple times they will both equip if they are the same item. For example I bought two swords from the merchant and when I equip it they both become equipped. However I can sell them individually. Any one else run into something like this?
Ah, you're right. That's a bug indeed and it happens because we're referencing the same entity that we first set in the merchant's inventory array. I think we need to create a new object every time the player buys a new item (similar to when we load items from a save file). This will need a little refactoring so I'll update the code in the next video. Good catch and thank you for pointing this out!
@@RyiSnow cool! glad i'm not alone on this one. I made a temporary fix that makes it so if and item isn't a consumable the item is removed from the merchant on purchase. So you can buy multiple potions but only one of each equippable item
if(npc.inventory.get(itemIndex).type != npc.type_consumable) { npc.inventory.remove(itemIndex); } temporary fix but feels a little better with this implemented was also thinking could make it so he doesn't let you buy a non-consumable item if it exists in your inventory
If someone was facing a problem that when they talk with the merchant, the merchant follows the player, the fix is easy, just add a solidArea Configuration: solidArea.x = 15; solidArea.y = 21; solidArea.width = 25; solidArea.height = 30; solidAreaDefaultX = solidArea.x; solidAreaDefaultY = solidArea.y; Hope this helps :)
Hi RyiSnow, I have a problem on my. When I run the game and I to npc merchant, I hit buy and I could not move the box to the next. But I can hear the sound are moving and I don't why is that. I did everything is right but I don't why is not working. Here is my code: public void playerInventory(int code) { if(code == KeyEvent.VK_W) { if(gp.ui.playerSlotRow != 0) { gp.ui.playerSlotRow--; gp.playSE(9); } } if(code == KeyEvent.VK_A) { if(gp.ui.playerSlotCol != 0) { gp.ui.playerSlotCol--; gp.playSE(9); } } if(code == KeyEvent.VK_S) { if(gp.ui.playerSlotRow != 3) { gp.ui.playerSlotRow++; gp.playSE(9); } } if(code == KeyEvent.VK_D) { if(gp.ui.playerSlotCol != 4){ gp.ui.playerSlotCol++; gp.playSE(9); } } } public void npcInventory(int code) { if(code == KeyEvent.VK_W) { if(gp.ui.npcSlotRow != 0) { gp.ui.npcSlotRow--; gp.playSE(9); } } if(code == KeyEvent.VK_A) { if(gp.ui.npcSlotCol != 0) { gp.ui.npcSlotCol--; gp.playSE(9); } } if(code == KeyEvent.VK_S) { if(gp.ui.npcSlotRow != 3) { gp.ui.npcSlotRow++; gp.playSE(9); } } if(code == KeyEvent.VK_D) { if(gp.ui.npcSlotCol != 4){ gp.ui.npcSlotCol++; gp.playSE(9); } } } public void tradeState(int code) { if(code == KeyEvent.VK_ENTER) { enterPressed = true; } if(gp.ui.subState == 0) { if(code == KeyEvent.VK_W) { gp.ui.commandNum--; if(gp.ui.commandNum < 0) { gp.ui.commandNum = 2; } gp.playSE(9); } if(code == KeyEvent.VK_S) { gp.ui.commandNum++; if(gp.ui.commandNum > 2) { gp.ui.commandNum = 0; } gp.playSE(9); } } if(gp.ui.subState == 1) { npcInventory(code); if(code == KeyEvent.VK_ESCAPE) { gp.ui.subState = 0; } } } Can you help me with this code, and see is there I need to change. Thank you!
Hi, I had the same problem, it happens in the two first lines of the "if statement of cursor" Here is the old one : if (cursor == true) { int cursorX = slotXstart + (slotSize * playerSlotCol); int cursorY = slotYstart + (slotSize * playerSlotRow); int cursorWidth = gamePanel.tileSize; int cursorHeight = gamePanel.tileSize; And here is the good one : if (cursor == true) { int cursorX = slotXstart + (slotSize * slotCol); int cursorY = slotYstart + (slotSize * slotRow); int cursorWidth = gamePanel.tileSize; int cursorHeight = gamePanel.tileSize; Just change playerSlotCol and playerSlotRow to slotCol and slotRow I searched for 2 days and looked at this passage at least 4 times before noticing my mistake. I hope it could help you or someone else :)
I love these videos. explaination is so good. i learned a lot watching these than sitting in class.
I've now completed everything up to this tutorial. I didn't expect to be so invested in this series, but I feel like I'm learning so much everyday. My wife had to pull me away from the computer the past few nights because time simply flies while following along with your explanations. You are so knowledgeable of Java. Do you develop games for a living? It's nice being able to code a game and brush up on my Java at the same time. Mostly use Typescript these days aside from Java Spring on the backend. Thanks again!!
If you have the issue I did, that you get to around 15:45 and you cannot talk to the NPC through the table, make sure the NPC has not moved. My table was not stopping the NPC from changing position and he walked 2 tiles south before bumping into the table and I could not talk to him. I moved the table one tile south of his start position so he did not move, and it worked.
A new video, a new masterpiece from our dear RyiSnow!
thank you for the video! I wanted to know, and when the video about saving the game comes out - I'm really looking forward to it)
Shortly before the end of this series!
Please never stop doing this. It helps me so much! Thank you!
Your game is getting better and better, in your next episode could make a menu of key configuration (a new tab of the menu option for example). good day
wow!! almost 1 hour of video is great!!
Great job Ryi, keep it up!
The original footage had nearly 2 hours lol It took time to edit it to 47 minutes!
@@RyiSnow wow!
Yeah good job ryi! This is exactly what we needed. ^_^
Thank you so much for making these videos. You always explain everything so well. By the way - were you thinking about adding a minimap?
It's great to see you back with another master class :D
I was thinking that would be interesting you could compare the items you're buying with the ones you have equipped, so you could see if those improve or decrease your stats.
The other thing i was wondering is that as it is now, you could sell the things you have equipped, right? So when you sell your shield it automatically unequips itself from your inventory?
Thanks as always, sensei
You cannot sell equipped item as we handled so in this video.
The weapon/shield comparison is a good idea. That said it's not difficult to implement it. You just need to display the attack/defense value of your current equipment and also the currently selected item. Try creating a sub window and display the value in it.
@@RyiSnow thanks for your patience and your answers!
@@RyiSnow I did this but it only shows the value of the CurrentWeapon = new OBJ_Normal_Sword(gp) in the player class. I cannot for the life of me get it to show the current weapons description. Also, this is for comparing what I have in my inventory to what I have equipped. I understand what you're saying about the subwindow with the traders inventory.
I love this tutorial and I learn a lot! Thank you thank you and thank you you are the best
when you have the dealer's slots, you can walk with the marker in more boxes than there is room for.
is there a shortcut to close/compress all the sections inside one class? I've seen how sometimes all the sections you have are closed and that makes it easier to find things
If you're using Eclipse, Ctrl+Shift+NUM DIVIDE will do it. You can also customize shortcuts from Window>Preferences>General>Keys
Hi, I have a problem when executing the drawInventory() method. When choosing trade_buy() in the game, an error appears in the console that entity is null. When checking through the debugger, I got to the point that the Entity npc variable in the UI class is null. How to fix it?
i need help about something.When i change map i located a npc.At located position i can talk with npc but npc was located 6 col away throught right.I can talk with a blank space and when i move, npc is moving oppositely with whenever i press keys.It s like a visual bug.Blank space is holding and not moving as i want and i can talk to him.
Hi there, i want to let the NPC stand still at one place, but whenever i move close to NPC, it moves in the opposite direction as me. Can somebody help me fix this :(
Just in case anyone was having this problem, the player's items were not showing (but they obviously existed and were there, since I could use a red potion even if the image wasn't showing) this is the solution:
Both the Entity class and the Player's class had this line:
public ArrayList inventory = new ArrayList();
it will cancel if it's in both classes, since the player extends Entity
I figured it out because the NPC didn't have that class and that one was working fine
Just delete that line from the player's class and you're good to go
I've been having an issue for a while now and can't seem to fix it. When interacting with an NPC, the dialogue gets drawn inside the dialogue box once, but it also gets drawn a second time outside the text box. This happens for every dialogue box though, so for the trading windows my screen is just covered in multiple instances of the same text. I can't seem to figure out where I've gone wrong with it, any help would be greatly appreciated.
As far as I know i've followed th code almost identically, but guessing there is an issue with one of my methods such as 'addMessage', 'drawMessage' 'drawDialogueScreen', 'speak'. Or it could be something to do with setting the state somewhere.
If anyone has faced this issue or can help i'd be extremely grateful, thanks
I have been learning a lot from these videos. I was wondering if you could make one with a form of “questing” system or if that would not be a part of this course
Hey again! I have this problem where when you enter map 2 to meet the merchant, it takes a few seconds for it to appear. What could be the cause of this? Any particular place that comes to mind if this happens?
The old man NPC also takes some time to appear now.
Thanks!
💕Amazing! You always do a wonderful job😍Will you cover the game deployment part like JAVA Web start or any other alternative user-friendly way?
Hey, I would like to see your approach on stackable items 😁 I used Gson for this but maybe there is a better method?
Wow that's amazing! There is one little bug, when you try to buy smth when you have not enough money, but coins keep go minus ...
Hi! Can u please make it so that u can save the game using SQL(database)? I really need it for my school project please :(
Hey, I was wondering if you could make a video on how to make in game cutscenes
Hi, please help me. I am trying to create a way of knowing if an item is in the players inventory. I want to require a key to be in the inventory in order to use it but i can't figure out a way to make an if statement like inventory.contain(OBJ_Key); but that doesn't seem to work. If you could help me out I would greatly appreciate it.
You can use item name.
Like this: inventory.get(i).name.equals("Key")
Is there a way to give each npc its own font?
Uhm im having this really weird problem where only the merchant's item's get drawn. I can select items from the players inventory and use them aswell but they don't show up as sprite so i cant see the items. I would really appreciate some help thx.
Hi did you find a solution because Im running into the same problem
Hello Ryi I have question about how works NPC in that program.
To be accurate I am wondering about that part in NPC construct:
solidArea = new Rectangle();
solidArea.x = 8;
solidArea.y = 16;
solidAreaDefaultX = solidArea.x;
solidAreaDefaultY = solidArea.y;
solidArea.width = 32;
solidArea.height = 32;
What it does ? Also if I delete this part then Merchant starts moving after talking with him in player's opposite direction. But if I delete this part in Old_Man then nothing changes.
Also I do not remember writing it in part#14
It sets the solid area where collision is detected. Check the Part 6 if you're not sure what it does.
@@RyiSnow Thank you!
I love your videos.
I'm trying to get to so you can have more than one store, but the other merchant takes over completely.
i fixet it :)
How would I scale a custom image to become the title screen backround? (instead of a set fillrect color)
You can use drawImage
@@RyiSnow Oh yeah just figured that out. Been here since tutorial 1! Really learned alot and have tailored alot of things sfter learning from you how to implement my ideas. THANK YOU RYI SNOW!
Your vids are great! Do you think you could do a multiplayer tutorial with 2d?
Can you please help us create and implement a countdown timer function? Like let s pretend we have in the right corner of the game screen a timer with 3 minutes left and if you don't do a task in these 3 minutes the level restarts or something.
Thank you for everything you ve done!
It s not suitable for your game ofc, but it will really help some of us..
Check the part 10. We handled a timer in that video!
@@RyiSnow i dunno how i missed that. Thank u so much🫡
So when you're making this. Are you skilled enough on your programming skills that you're making it the most efficient way? Like is this the best way to make this game from scratch? Or when you are editing do you see you can make better tweaks to your code? I'm still new to coding I'm sure curious. Good Job! Anyways
Only thing I can say is you never know what the "most efficient/best way" in coding. Even if you are the most talented programmer in the world, you might come up with a better way tomorrow, to handle what you wrote yesterday. There is no absolute way in coding and everyone has their own style.
@@RyiSnow Thanks!
Thanks!
oh cool, you're also working on an rpg right now??
hi, i'm making a rougelike game base on your videos, can you show me the way to keep all the coin the character gained after he died
We're keeping player's coin as well as his items even after he dies. We handled it so in the Game Over video.
Hi! Can you make a video using databases (Sql) for the game? Please!
Please👉👈
Thanks a lot
Super!!!
thanks
Hey. this completely broke my inventory (pressing c, not npc).
I had the same issue. I fixed it by going to the Player class, and deleting this line of code:
public ArrayList inventory = new ArrayList();
im 16 minutes in and I dont get a dialogue screen when i try to speak from across the table, i just get frozen game with no error, made me think of another way to handle merchants behind counters...
EDIT: figured out my issue. I did not have 'i=0;" under 'mapNum = 1;' in AssetSetter
different merchant idea
Make the table the merchant, so you are actually interacting with the table and the merchant npc is more so a dummy. If you have a merchant thats not behind a table you could just have the merchant interact as you do now. Maybe making the table have a little cash register and if you speak to a merchant thats behind a counter the just say something like "please speak with me at the register to purchase or sell any items"
i have a large request too , any chance you could add a slot machine ? I want to make a casino similar to the ones in original Pokemon. Now that we have NPC we could use that to exchange for 'casino chips' and have another one with prizes. Im thinking the slot machine would work alot like the enemy drops. Would need some basic slot reel images also like cherries, 7s, BAR sign, etc. You could have a losing spin display a variety of losses ( ie 7 Cherry Bar or like Bar Cherry Cherry) , and then winners display like " 7 7 7 or Cherry Cherry Cherry" and gives player chips
Sorry but slot machine is more like a flavor mechanic and it's a bit out of theme of this tutorial. I need to take care of fundamental mechanics first otherwise this series will never reach the end!
Handling the table itself as NPC is actually an interesting idea but the problem is you can talk to it from left and right side too and that would be a bit strange since player is not facing the actual NPC that way. Still it can be a hint to solve this issue so thanks for the suggestion.
@@RyiSnow thanks for the reply! Slot machine defiantly a flavor mechanic, and totally get how it could be never ending series (we all low key want this series to never end lol)
I think ill create a vending machine to use later, cause i figured out what my issue was that led me to thinking of the npc table merchant idea.
Also, what is your next plan for a series? I am so interested in whatever it will be.
Hi sir, I have watched all your videos in this playlist and they really are helpful to me who is a slow learner
in programming.
One problem I am facing is that when I try to go to location( worldX - 888, worldY - 1916 OR worldX - 724, worldY - 1560 or somewhere under that area), the program stops and show several run-time errors (BTW I am using netbeans 8.1) and
one of them is " Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException "
"at tile.TileManager.draw(TileManager.java:114) ".
I hope u find my problem solution.
Thank you very much.
Sounds like you're trying to draw a null object so that's what you want to check.
@@RyiSnow But it is strange that it only happens in worldV3 but not in worldV2 or in any
other maps . Btw could u place a pixel house on right top of the map where the player first appears?
@@aunglinn6377 Did you instantiate those new tiles?
@@RyiSnow Damn!!! It is my DUMB mistake!!!
When I test to place an trunk on the map, I instantiated and placed on the .txt file but I totally forgot to change the tile number 42 to 41 after deleting the instance. LOL!!!
So sorry for wasting ur time! And thank you very much for your help.
🥰🥰🥰
possible to make it multiplayer as well?
Hi! Can you make a video using databases(SQLite) for the game? To have score. Please
He already have a video for it
How would you make a RPG battle like Earthbound?
You can handle it by creating a game state but I can't really explain everything in a comment.
Everything is working great however there is one small bug. You can buy and sell items fine but if you buy something like equipment multiple times they will both equip if they are the same item. For example I bought two swords from the merchant and when I equip it they both become equipped. However I can sell them individually. Any one else run into something like this?
Ah, you're right. That's a bug indeed and it happens because we're referencing the same entity that we first set in the merchant's inventory array. I think we need to create a new object every time the player buys a new item (similar to when we load items from a save file).
This will need a little refactoring so I'll update the code in the next video. Good catch and thank you for pointing this out!
@@RyiSnow cool! glad i'm not alone on this one. I made a temporary fix that makes it so if and item isn't a consumable the item is removed from the merchant on purchase. So you can buy multiple potions but only one of each equippable item
if(npc.inventory.get(itemIndex).type != npc.type_consumable) {
npc.inventory.remove(itemIndex);
}
temporary fix but feels a little better with this implemented
was also thinking could make it so he doesn't let you buy a non-consumable item if it exists in your inventory
can u make it in godot engine?
If someone was facing a problem that when they talk with the merchant, the merchant follows the player, the fix is easy, just add a solidArea Configuration:
solidArea.x = 15;
solidArea.y = 21;
solidArea.width = 25;
solidArea.height = 30;
solidAreaDefaultX = solidArea.x;
solidAreaDefaultY = solidArea.y;
Hope this helps :)
Hi RyiSnow, I have a problem on my. When I run the game and I to npc merchant, I hit buy and I could not move the box to the next. But I can hear the sound are moving and I don't why is that. I did everything is right but I don't why is not working.
Here is my code:
public void playerInventory(int code) {
if(code == KeyEvent.VK_W) {
if(gp.ui.playerSlotRow != 0) {
gp.ui.playerSlotRow--;
gp.playSE(9);
}
}
if(code == KeyEvent.VK_A) {
if(gp.ui.playerSlotCol != 0) {
gp.ui.playerSlotCol--;
gp.playSE(9);
}
}
if(code == KeyEvent.VK_S) {
if(gp.ui.playerSlotRow != 3) {
gp.ui.playerSlotRow++;
gp.playSE(9);
}
}
if(code == KeyEvent.VK_D) {
if(gp.ui.playerSlotCol != 4){
gp.ui.playerSlotCol++;
gp.playSE(9);
}
}
}
public void npcInventory(int code) {
if(code == KeyEvent.VK_W) {
if(gp.ui.npcSlotRow != 0) {
gp.ui.npcSlotRow--;
gp.playSE(9);
}
}
if(code == KeyEvent.VK_A) {
if(gp.ui.npcSlotCol != 0) {
gp.ui.npcSlotCol--;
gp.playSE(9);
}
}
if(code == KeyEvent.VK_S) {
if(gp.ui.npcSlotRow != 3) {
gp.ui.npcSlotRow++;
gp.playSE(9);
}
}
if(code == KeyEvent.VK_D) {
if(gp.ui.npcSlotCol != 4){
gp.ui.npcSlotCol++;
gp.playSE(9);
}
}
}
public void tradeState(int code) {
if(code == KeyEvent.VK_ENTER) {
enterPressed = true;
}
if(gp.ui.subState == 0) {
if(code == KeyEvent.VK_W) {
gp.ui.commandNum--;
if(gp.ui.commandNum < 0) {
gp.ui.commandNum = 2;
}
gp.playSE(9);
}
if(code == KeyEvent.VK_S) {
gp.ui.commandNum++;
if(gp.ui.commandNum > 2) {
gp.ui.commandNum = 0;
}
gp.playSE(9);
}
}
if(gp.ui.subState == 1) {
npcInventory(code);
if(code == KeyEvent.VK_ESCAPE) {
gp.ui.subState = 0;
}
}
}
Can you help me with this code, and see is there I need to change.
Thank you!
Hi, I had the same problem, it happens in the two first lines of the "if statement of cursor"
Here is the old one :
if (cursor == true) {
int cursorX = slotXstart + (slotSize * playerSlotCol);
int cursorY = slotYstart + (slotSize * playerSlotRow);
int cursorWidth = gamePanel.tileSize;
int cursorHeight = gamePanel.tileSize;
And here is the good one :
if (cursor == true) {
int cursorX = slotXstart + (slotSize * slotCol);
int cursorY = slotYstart + (slotSize * slotRow);
int cursorWidth = gamePanel.tileSize;
int cursorHeight = gamePanel.tileSize;
Just change playerSlotCol and playerSlotRow to slotCol and slotRow
I searched for 2 days and looked at this passage at least 4 times before noticing my mistake.
I hope it could help you or someone else :)