Java Programming: Let's Build a Game #14

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

In this episode we add a shop into our game making it so we can upgrade our player! If you have any questions then be sure to leave a comment or contact me on twitter @realtutsgml. If you learned something then be sure to leave a like, comment, and favorite.

Visit CodingMadeSimple for more exclusive tutorials and get the help you need to succeed as your very own indie game developer!

Follow me on twitter for exclusive content and interaction with me!

Follow me on Google+ to keep updated with all of my tutorials

Game Maker Studio: Programming
Game Maker Studio: Tutorial
Java Programming
Game Programming
Game Tutorial
Programming Tutorial

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

Great video!!
Just few things I found that may help out:
- If a player clicks on any of the box positions while not in the shop, it will still interact. Have the mousePressed check if the game state is set to shop first.
- I used an enum for the shop products.
Example:
enum ShopProduct {
HEALTH_BOOST("Health Boost", "It increases the health points", 1000),
SPEED_BOOST("Speed Boost", "Increases the movement speed", 2000),
setter, getters, constructor, and variables here

ehabmoustafa
Автор

I'm not sure why it seems others have gotten the lines of code in around 7:02 to compile, but I ran into the "Non-static variable cannot be referenced from a static context" error when compiling. Turns out you are supposed to replace all "Game.gameState" with "game.gameState" (lower case g), since you are referring to the instance of the Game object, which is already instantiated above in the KeyInput class as 'game'. Just something to point out for others who follow this great tutorial series.

Edit: Also, a heads up that by the end of this tutorial series, the game will still have bugs to sort out for e.g. purchased upgrades from shop carrying over on a restart etc. that you may want to fully test and sort out on your own.

Nora-bycp
Автор

RealTutsGML: buys extra speed about 8 times
The game: YOU ARE A SPEEDY BOI NOW

spongewent
Автор

Just wanted to say thank you for your tutorials and to encourage you to continue them.
I'm really enjoying them and am looking forward to the next one.
Keep up the good work!

MintWithTheHole
Автор

Can you do a tutorial on making saved files?

ValorDucky
Автор

Glad to see that the shop will finally have its turn in the spotlight and created. I've had some ideas for and RPG mode in Pixel paintballers. PLEASE keep up the outstanding work, It's what inspired me to create my game. Also, please show how to create custom save files please.

r.graham
Автор

yay the shop in your game was that thing that stood out to me

OskarFFS
Автор

I've got a problem. I have the shop working just fine, and the speed and health options go up in cost whenever I buy them again.
However, lets say I got 2 health upgrades so they now cost 3000. If I die and click Try again, in my next game instead of going back to 1000, its still 3000. Any help would be appreciated!

olivergriffin
Автор

Small fix for a problem I discovered about the shop menu, it remains active even when the shop isn't open for me (might've typed some code wrong idk) but if anyone else is having this issue, put the actual box detection functions inside of an if statement that checks if the current state of the game is the Shop (I don't know terminology well but essentially wrap it in this)

if( Game.gameState == STATE.Shop )
{
// box 1
(code stuff)


// box 2
(code stuff)

// box 3

(code stuff)
}


Then again this code may not work for everyone but it worked for me.

gushcraftgaming
Автор

What about fixing the problem with the particles being rendered below the player and enemies (or not render where they are if possible) so we can also show the sprites

plus instead of a simple power up that just appears (that could be added to the game) that you have to go and "grab"
what if that was an outline of a huge circle or rectangle that would shrink to a certain size over a short period of time and if you are in that area at the end of the shrink "animation"/powerup then something good happens

probably explode all nearby enemies (clearEnemies() if they are in the area of "something")
that something could be -100, 100 around the player, the area you already used for the power up or something

or simply just slow the enemies for a few momments


thank you for making these videos, we really appreciate it and we hope to see more of these

JmasterOFdeathL
Автор

This is so cool!
Great way to start learning the game dev basics

cleojohnmarkpamienta
Автор

For some reason nothing happens when I click on my box 3. The other boxes work fine. If I switch the order of the boxes it's always the last one in the code that doesn't work.

alabasterwanted
Автор

I have a quick question. In the shop class, you have a render method. In this method you create a new instance of Font every time render is called. Does this have any minor effect on performance? Would it be more efficient to set these fonts as variables at the top of the class and refer to them using their variable names?

HazStepFTW
Автор

hey, uh, could anyone please explain how the mouse listener width, height thing works.
i was making a new shop item, everything works except the mouse listener location input.
g.drawRect(100, 170, 100, 50);
this is the rectangle i drew.
(mx >= ?? && mx <= ??)
(my >= ??&& my <= ?? )
pls tell me what to put instead of the ?? signs.

atmosfear
Автор

Always love every tutorials for making game you've given! Thank you so much!

albertuse.s.sutanto
Автор

I've seen this in the comment section before, but no one could make my shop not have this problem. Whenever I get something in the shop, like the add health, and I die, when I go back to the game, the score needed to buy the health stays the same as if I bought it before, and the effects stay as well. Can someone reply and tell me how to make it so if you die, the effects reset to before and the score needed to buy it goes to before? Thanks.

yoink
Автор

Hey I'm really enjoying your tutorials so far! Would be great to see more Java tutorials on different games maybe? Thanks!

erickim
Автор

You make me to start learning Java. I don't know why... Until now I stucked with C++...

alin.pisica
Автор

anyone know how to make an enemy like the one he had in the demo of wave 2 where they come in rows of 6 and there is one space to go through??

ValoriumOfficial
Автор

I made it up until the upgrading health part, but when I collide with an enemy I get a NullPointerException.

I have written stuff exactly like you did.

Jonaks
welcome to shbcf.ru