Does anyone else spend 5min playing there unfinished game between episodes? :D
@EnergixCoding
4 жыл бұрын
YES!!! YES. YES.
@beethebuilder6191
3 жыл бұрын
yes
@userunp
3 жыл бұрын
i can relate to that
@nostalgia5031
3 жыл бұрын
Me, the stuff in this video made it super fun!
@alnoiseplaysmc
9 жыл бұрын
Dude you're videos are so amazing, not only do you teach us how to make amazing things, but you explain how everything works. Unlike a lot of KZitemrs who just tell you what to type, you give us options. Props to you man. 2 Thumbs up!
@leonardscheerer5971
7 жыл бұрын
Same
@iradnuriel9087
5 жыл бұрын
You should have an abstract class named Enemy , that extends GameObject end all types of enemies extends her, it will make the code a lot shorter
@anpapala5961
9 жыл бұрын
Finally you are back, way you are taken so long between your videos. I'm so happy you are back to help me to improve my knowledge.thanks
@RealTutsGML
9 жыл бұрын
PC crashed but I should be back to making videos regularly again! Thank you for your patience
@GPlayerHD
9 жыл бұрын
Yes!!! Thanks for be back dude, was afraid of you don't keep the series, this is helping me a lot, thank you!
@monugupta32
9 жыл бұрын
Another great tutorial.. loving it.. Two thing for other users to make it better: 1. set redColor variable=0 & in tick method do redColor=255-greenColor; &obviously paint it. It'll give a smotth green>yellow>red bar transition 2. Extends Fast enemy to basic enemy so needn't to copy code & just change the color and speed in constructor.. remember DRY CODE!
@awelotta
8 жыл бұрын
Yeah, he should have made an enemy class underneath the GameObject class for better organization and less work. It is easier to add new enemies that way.
@monugupta32
8 жыл бұрын
It's been one year.. & I actually forgot what I wrote.. & that worked on java.. XD.. But i'm learning in phaser (game dev) these days.. coz js is my life now.. :)
@jakemoody8551
9 жыл бұрын
yes real tuts is back i've been waiting so long and it was my birthday on friday so its a birthday gift keep up the amazing work
@RealTutsGML
9 жыл бұрын
Happy Birthday!
@jakemoody8551
9 жыл бұрын
:0
@spiritwolf448
7 жыл бұрын
DUDE! You could just do (to add the level) score++; if (score % 1000 == 0) { level++; } basically, % gives you the remainder of a division. So, if the remainder of score / 1000 is 0, then it has to be a multiple of 1000! yw
@andrewhayworth2157
8 жыл бұрын
For the code handling the level progression, can't you just put this int the tick method for hud: if(score % 1000 == 0) level++;
@englishcrusade
8 жыл бұрын
Good vid! If I might make one suggestion... When creating the second enemy, it would be a great idea to explore Object Inheritance. From the look of it, there shouldn't be too much code to add and it explores an extremely important concept in both Java and game programming. Keep up the great work!
@Phenylalanin1979
9 жыл бұрын
Thanks for the tutorial. Next up for me would be sound effects, background music etc. Other than that, a game over screen and perhaps a leader-board with all your high scores.
@mikaelkolehmainen9098
4 жыл бұрын
I have been having a blast creating this, I have to learn Java for my work experience program. PS. I am 14
@jackyjack3193
3 жыл бұрын
Shut up bitch
@jplay9340
5 жыл бұрын
If you want to make the Score going slower like I did: private double Score = 0; instead of int Score Score = Score + 0.?; instead of score++; while the ? has to be replaced as you wish, I prefer 0.1 (or higher if u use 60 ticks) g.drawString("Score: " + (int) Score, 550, 20); to cast the double to int before showing it to get rid of the after comma numbers again
@timbsswag
6 жыл бұрын
There is an easier way to increase the level value every time the score hits 1000. In the tick method in the HUD class, type... if(score % 1000 == 0) { level++; } This is using the modulo operator ( % ) to check the remainder of a quotient. If the score divided by 1000 has a remainder of 0, increase the level.
@redstone_mason
4 жыл бұрын
You can make the health bar turn into a brighter red by replacing g.setColor(new Color(75, Health *2 + 55, 0)); with g.setColor(new Color(255 - Health * 2, Health *2 + 55, 0));
@spongewent1479
3 жыл бұрын
9:42 i recommend doing the score for a long variable because if u want high scores, but it needs more memory 20:07 when the enemy spawns it spawns in tons of amounts and made by FPS super low, so i disabled him
@henryredder5109
8 жыл бұрын
YAY it works (: good job with the video realtutsgml
@scifi7686
6 жыл бұрын
There is an alteration you can make to the code that allows you to set the red value to 255 without altering the green hue at all. private int greenValue = 0; private int redValue = 255; public void tick(){ HEALTH = Game.clamp( HEALTH, 0, 100 ); greenValue = Game.clamp( greenValue, 0, 255 ); greenValue = Game.clamp( redValue, 0, 255 ); greenValue = HEALTH * 2; redValue = ( ( 100 - HEALTH ) * 2 ) + 55; } public void render( Graphics g ){ g.setColor( Color.black ); g.fillRect( 45, 45, 600, 96 ); g.setColor( new Color( redValue, greenValue, 0 ) ); g.fillRect( 45, 45, HEALTH * 6, 96 ); g.setColor( Color.white ); g.drawRect( 45, 45, 600, 96 ); } Essentially, changing the red value inversely as well as the green value.
@ancientalienmusic
7 жыл бұрын
The Levelup would be much easier with % (modulo)! In my HUD class, in the tick() method I just wrote "if(score%1000 == 0) level++;" It means that everytime the Score reaches 1000 the Level goes one up. Because 1000/1000 is divideable and the divisionrest is equals to 0. For 328/1000 the divisionrest is equals to 328. For 3547 the divisionrest is equals to 547. For 10000/1000 the divisionrest is 0 => its true... and so on
@amuzak9063
5 жыл бұрын
I have found this code to be a little cooler for the transition: //initialize outside tick() private int gVal=255; private int rVal=0; //within tick() gVal=255*HEALTH/100; rVal=225*(100-HEALTH)/100; //within render(Graphics g) after the grey box has been created g.setColor(new Color(rVal,gVal,0)); g.fillRect(15, 15,HEALTH*2, 32);
@xTsukeo
8 жыл бұрын
Why not do something like this for level change: if(score % 1000 == 0) level ++; ? Worked for me
@amuzak9063
5 жыл бұрын
Was thinking the same thing, I'm sticking with this
@janssonjr1
9 жыл бұрын
Good tutorials!! :) I would like to see images, start menu, pause menu and music/sound.
@slice_of_pizza6219
7 жыл бұрын
I caught something you forgot. I am still learning, but I found that the fastEnemy does not do damage. Even though you kept dodging it, it did not do damage for me. You forgot to make the collision code for fastEnemy. I was able to figure out how to fix it though. All those tutorials help. But I do get a null pointer in my game class. It is spawner.tick(); and tick(); in my game loop. How do I fix that? Other than that your vids are really informative and teach me a lot. I even added some of my own touches (and ignored some of yours (that I might use)). I am doing this for the science fair and these videos are saving my grades. Thank you!
@steve24822
9 жыл бұрын
Instead of greenValue = HEALTH*2; I did: if (HEALTH < 25) { greenValue = 0; } Turns to red when low instead of a gradual change.
@xavierjones9313
5 жыл бұрын
this line of code causes the game to crash when it tries to reach level two.... handler.addObject(new BasicEnemy(r.nextInt(Game.WIDTH), r.nextInt(Game.HEIGHT), ID.BasicEnemy, handler)); ........... i did everything u said and re watched the video at least 5 times and everything is correct. please help asap
@maxgerbens
2 жыл бұрын
I'm a bit late but maybe I can help someone else with it. In your game.java make sure you declare your handler before declaring spawn.
@baphnie
3 жыл бұрын
Instead of having two variables that represent 'score' in different scopes, I did -- public void tick() { hud.setScore(hud.getScore() + 1); if (hud.getScore() % 100 == 0) { hud.setLevel(hud.getLevel() + 1); } }
@dougg8452
4 жыл бұрын
Hi instead copy and paste Enemy code into FastEnemy, maybe its better to use FastEnemy extends Enemy? In that case we only change the velX velY into FastEnemy constructor.
@SlylentGamer91
9 жыл бұрын
Nice
@debmart59
9 жыл бұрын
Very informative vid
@mhosk833
2 жыл бұрын
Hi anyone watching in 2022 :P I had the same issue with fall through on the colors changing. When a FastEnemy spawned, it changed the color of all existing enemies to CYAN. I added this.color = color inside the Trail class and seems to have fixed it :)
@RealTutsGML
2 жыл бұрын
Great job solving your problem! Good luck
@xe54studios12
9 жыл бұрын
YES baby!
@janssonjr1
9 жыл бұрын
If you can, i would love to see how you make gravity in a game. That would be AWESOME!! :D
@RealTutsGML
9 жыл бұрын
kzitem.info/news/bejne/qWebq51_aoVnf3Y
@janssonjr1
9 жыл бұрын
AWESOME!! :D But maybe multiplayer later on? :)
@amirhosseinebrahimi5239
5 жыл бұрын
man i owe you
@firashashash7371
8 жыл бұрын
Thank you for these great tutorials!! But is there a way to make the game use less CPU :( ...
@h3egypt
7 жыл бұрын
a switch for the spawner with cases 1 2 3 is simpler
@flashp0ke
7 жыл бұрын
Why didn't you create an interface with tick and render methods instead of typing them in every class?
@alexandergillberg8023
9 жыл бұрын
Would love to learn how to draw images in this code. been trying for hours now, but can't find a way to get the images drawn onto the screen using the render methods in. big thumbs up for ur channel, love it!
@ShaharHarshuv
7 жыл бұрын
"down into that red and then we're dead."
@lukefuller284
9 жыл бұрын
Lol, the "duplicate" button is in GameMaker.
@thelogicalgamer8175
8 жыл бұрын
How I executed the color changing health bar: g.setColor(Color.GREEN); g.fillRect(15, 15, HEALTH * 2, 32); if(HEALTH
@stefthegreatest1380
8 жыл бұрын
+TheLogicalGamer same
@06-hochunguckhanh29
8 жыл бұрын
I think if the color changes slowly from green to yellow and then red, it'd be more cool!
@andreaspg123456789
7 жыл бұрын
In case people still read this, and want an actual smooth transition, I did this by using the following: greenValue = HEALTH*255/100; g.setColor(new Color(255-greenValue, greenValue, 0));
@zebrapositions
6 жыл бұрын
i think this looks rather nice: if (HEALTH >= 100) { greenValue = 255; } else if (HEALTH
@LeyronMirox
9 жыл бұрын
Thx!!!!
@areejshama5698
8 жыл бұрын
i want that the score not raise like this i will add class name it fruit and it's randomly appear on the game and the player eat it and the score raise .. can you help me do that ??
@FlamingKnight
6 жыл бұрын
Did you mean velocity x and velocity x? or velocity x and velocity y? 18:15 in your video
@nostalgia5031
3 жыл бұрын
The 7 dislikes are people who didn't follow the instructions and got null pointers.
@cameronyates8404
9 жыл бұрын
I've been trying to add some code that makes the basic enemy bounce off of the player once it collides to really show that the enemy hit you, but everything I've tried has been an error (this really relates more to part 5 by the way) do you think you could possibly help me out and give me an example of what it would take to accomplish this? Love your videos man thank you so much!
@stevenkitchener2719
9 жыл бұрын
If you want a simple deflection i.e. if the enemy is moving right make it move left once it hits the player. then all you have to do is times the velocity of x by -1; if you want a change in direction in both axis, i.e. enemy moving NE, change to SW, then times both velocity y and velocity x by -1; to get a more complex deflection you'll have to play around a little bit but the most important thing is using the *-1 to change the direction. Good Luck.
@NumianVonKami
8 жыл бұрын
i dont know why but the speed of the enemies that are created by the spawner have more speed than the ones y create at the beginning, anybody knows why?
@zenthepig404
4 жыл бұрын
When starting the game I get a white screen for about 10 seconds. Help
@firashashash7371
8 жыл бұрын
GUUUUUUYYYYS .... I FOUND A WAY TO BRING DOWN THE CPU UTILIZATION>>>>>>>>>>> Just put these lines of code in your main loop : "try { Thread.sleep(10); } catch (Exception e) { e.printStackTrace(); } " this should bring down the cpu usage alot!!!
@NXVIINXVII
9 жыл бұрын
LOVE THIS! would love a simple game menu if possible! :)
@ashwinkkudva
9 жыл бұрын
realtuts have u tried libgdx? It takes care of all of the trivial stuff, and has some really cool libraries not found in vanilla java. It can also be deployed to android and ios with no cost, so i dont really see the advantage of coding in java.awt
@Mietchannel
6 жыл бұрын
My basic enemies turn cyan whenever a fast enemy is added, anyone else have this problem?
@SneakyLunatic69
9 жыл бұрын
Anyone else getting random lag spikes or something every few seconds in their games? It will run smoothly for the first little bit, but then after 20 secs or so the game will stutter for half a sec and then everything will jump forward. Then it runs smoothly for a few seconds then stutters and jumps ahead. It keeps repeating this over and over infinitely...
@SneakyLunatic69
9 жыл бұрын
SneakyLunatic69 Also when I try to render the handler before the HUD and edit the HUD Class, when I try and run the game it crashes. If I try to open it again without changing anything in the HUD Class it will open no problem... Sorry if these are actually really easy fixes, I'm new to coding stuff XD Also, I can post my source code if needed.
@cannedchicken3466
6 жыл бұрын
This is great and all, but what program are you using so I can get started
@amirhosseinebrahimi5239
5 жыл бұрын
it's Eclipse
@kushalrahatkar4568
5 жыл бұрын
i want to increase my graphic quality. how can i do that???
@42paradigms
8 жыл бұрын
Quick question (or for anyone who may be able to help out) but when updating the collision method to include the new enemy types, I had the clever idea of instead to go with something like this while looping through the array instead of adding each enemy type and all, if(tempObject.getID() != ID.Player) I figured it would work since that includes everything in object except the player itself. However, I get a null pointer at the addition of the enemy objects in the game. I thought it might be something to do with the getBounds() method, but since the BasicEnemy is just C/P'd over then it should have a usable method there as well? Any ideas or suggestions on this would be helpful, or perhaps some insight on the boolean and array stuff I'm glossing over would be much appreciated! Great videos though! Uber-helpful in all aspects, especially those of us who are just getting into OOP and haven't the slightest clue on how to handle any graphics stuff!
@kcpgaming1
9 жыл бұрын
Do you recommend a game engine like unity for beginners like me who wanna get into 3D game development or should i learn all this stuff from just code and build my way up? i prefer java the most out of all the languages i've tried.
@mosstah
5 жыл бұрын
CAN ANYONE TELL ME HOW TO FIX THE ENEMYS SPAWNING OFF THE SCREEN???
@amirhosseinebrahimi5239
5 жыл бұрын
do x = r.nextInt(WIDTH - somevalue 1 )+ somevalue2; y = r.nextInt(HEIGHT - somevalue3 ) + somevalue4; calculate somevalue1 ,2,3,4 with debugging
@danielandrews1220
8 жыл бұрын
Does anyone know how to fix a problem? My problem: everytime I run the game my game goes white for about 2 seconds then my game pops up running perfectly.. Anyone knows how to stop the white delay?
@epictoasterwaffles4396
6 жыл бұрын
I also have this problem
@LuminearHD
3 жыл бұрын
Is there a way to create a player gameobject with out the loops? I feel like it might be more efficient for me since im trying to improve the movement. Ex: GameObject oh = handler.object.get(handler.object.indexOf(ID.Player)); obviously doesnt work but any tips?
@senlikshoots
4 жыл бұрын
When creating the fast enemy and making the color CYAN all the enemies change colors. Ive been trying to debug but cant hack it any ideas?
@danielhostetter8115
8 жыл бұрын
Can someone help me? When I run the game, I just get white in the display of the game. Sometimes the white will go away and my game will run fine, but more often then not it just stays white. There is no error signs in my coding. It's almost as thought my computer will only open the window but not open the game.
@lunchmenuu5389
8 жыл бұрын
Im having 2 problems, a lot of the times the enemy spawns on the sides or top or bottom and just goes side to side or up and down, and then after about 10 levels my game crashes and gives me an error. Exception in thread "Thread-2" java.lang.IllegalArgumentException: Color parameter outside of expected range: Green at java.awt.Color.testColorValueRange(Unknown Source) at java.awt.Color.(Unknown Source) at java.awt.Color.(Unknown Source) at com.tutorial.main.HUD.render(HUD.java:25) at com.tutorial.main.Game.render(Game.java:108) at com.tutorial.main.Game.run(Game.java:76) at java.lang.Thread.run(Unknown Source)
@zdravkojerzabek874
9 жыл бұрын
hi, so I've been folowig this series and I can't figure out the collision so it would be nice i you (or someone that has the code working) gives me the hud and the player class. Thanks
@RealTutsGML
9 жыл бұрын
The very end of the series I will release all of the code onto GitHub
@javafreak6584
9 жыл бұрын
give me your fb and i'll send u link
@zdravkojerzabek874
9 жыл бұрын
ok thanks RealTuts, if you want you can send me the code via email if you want, mine is inimanpro@gmail.com
@zdravkojerzabek874
9 жыл бұрын
Zdravko Jerzabek Cuz I'm kinda confused and it would be nice to get the code working because I'm adding my own little things
@lorenzvo5284
9 жыл бұрын
I did something funny in the Window class :D String[] a = {"Funny, isn't it?","I like cake!","I prefer Pi","Yo momma"}; frame.setTitle(a[r.nextInt(a.length)]); r is a Random;
@AdrenalatedGamR
9 жыл бұрын
Do you know python? I would like to see something made in that it seems like nobody likes that's coding language anymore or you could even try LUA
@asutoshvariar
4 жыл бұрын
Since Python is compiled as you run the code, there are very heavy performance penalties. Because Java compiles your code and then runs the compiled version, it is a LOT faster. That's why programming languages like Java and C++ tend to be used for games.
@joshuakobrin6909
6 жыл бұрын
Do you think you could help me add a background to the game screen?
@crew575
5 жыл бұрын
if you want i can help you
@linothehellbat4986
7 жыл бұрын
why when the game add a BasicEnemy it crashes?
@zenthepig404
4 жыл бұрын
heres a tip, show your code you inbred donkey
@Aisbejsijdns
2 жыл бұрын
whats the code for this tutorial? please reply to me beacuse i fked my code :(
@jewishbanana7055
7 жыл бұрын
Is it just me or does it sound like hes in FNAF one's office recording videos on the computer.
@jamesuk-dev
8 жыл бұрын
The score and level keep going up in sync, when the score reaches 1000, the level reaches 1000 aswell. I have tried to fix it but I am just not sure where I have gone wrong. Any hints on where to look. I'm sure i'm just being blind but it is at a point where i have no idea.
@thegamingsomebody3216
6 жыл бұрын
Does the drawstring output the score int or the level int?
@sittingonthelawn
9 жыл бұрын
Sometimes I get this error when I try to start my game, but I can't figure out what to do.... Seems to be something with the thread?? I'm not familiar with threads so if someone has a clue I'd be very thankful for some help :D Exception in thread "Thread-0" java.lang.NullPointerException at com.first.main.Game.render(Game.java:103) at com.first.main.Game.run(Game.java:71) at java.lang.Thread.run(Thread.java:745)
@erayski
5 жыл бұрын
when i write the code: hud.setLevel(hud.getLevel() + 1); int the Spawn class tick() method, it doesn't works all the getters setters are already written HELP!
@fenja9544
3 жыл бұрын
Do you have this.hud = hud; in your Spawn class? public Spawn(Handler handler, HUD hud){ this.handler = handler; this.hud = hud;
@elizabethcabbage9817
3 жыл бұрын
Pfft, I just made a red bar under my green bar so that as your health depletes it just no longer blocks the red bar.
@elizabethcabbage9817
3 жыл бұрын
also made a scoreReq that ramped up based off of the level so in my HUD tick method I did if(score >= scoreReq){ level++; scoreReq += (1000 * level); } so that each level the amount needed would go up by a thousand and this also prevented a lot of unnecessary code. You can still have a getLevel and getScore method, but I think the set methods along with "scorekeep" were both kinda unnecessary.
@loldirt2893
3 жыл бұрын
lazy
@RobertLopezAmateurFilm
8 жыл бұрын
how do i put the trail behind my Player?
@CustosMorum2010
8 жыл бұрын
+Robert Lopez He explains how closer to the end of part 5. It similar to how you do it for the enemies's trails.
@name-mb8co
8 жыл бұрын
I think he means how to put it BEHIND the player because it is rendered IN FRONT of the player in this tutorial lol
@zenthepig404
4 жыл бұрын
@@name-mb8co change its x and y position when adding it to the game
No because it doesn't tell the hud class that the level is increasing
@awelotta
8 жыл бұрын
If you are going to do it that way, you don't need scoreKeep: if(score % 1000 == 1000) level++;
@SZakiabba
7 жыл бұрын
Sometimes the enemy spawns outside of the window, even when I put: r.nextInt(Game.WIDTH-50),r.nextInt(Game.HEIGHT-50) and since I added sound when it hits the borders, you can repeatedly hear the "sound" since it's outside the border, how can I fix it?
@everyvk
2 жыл бұрын
Probably spawning at 0, do r.nextInt(Game.WIDTH - 100) + 50, and then the same for height, so it chooses a number from 0 to less then the width and then adds to it so it's a 50 margin on both sides
@joaopedroreis1444
6 жыл бұрын
i have a problema with the spawner every time it arrives to 999 to get lvl 2 he frezz and says this "Exception in thread "Thread-0" java.lang.NullPointerException at com.Game.main.Spawn.tick(Spawn.java:27) at com.Game.main.Game.tick(Game.java:92) at com.Game.main.Game.run(Game.java:73) at java.base/java.lang.Thread.run(Unknown Source)" but if i take out the new enemy spawn like this "if(hud.getLevel() == 2) { //handler.addObject(new BasicEnemy(r.nextInt(Game.WIDTH), r.nextInt(Game.HEIGHT), ID.BasicEnemy, handler));" the game still operacional but no enemy added to lvl. if someone know how to fix it i appreciate very much.(my english is bad sorry!)
@fuzailhasan7856
5 жыл бұрын
put r = new Random() above spawner. it worked for me I had the same problem public Game() { handler = new Handler(); this.setFocusable(true); hud = new HUD(); r = new Random(); spawner = new Spawn(handler, hud, r);
@cybercheese6948
9 жыл бұрын
Hey RealTutsGML can you or somebody who knows java help me with removing handler objects? bs i tried and it didn't work :/
@naxaes7889
9 жыл бұрын
ArturGames I probably won't be able to help you but if you post your code you'll most likely get help faster.
@cybercheese6948
9 жыл бұрын
k here it is: pastebin.com/zEJr24HS and i havent put everything in bc of reasons :D
@naxaes7889
9 жыл бұрын
ArturGames Okay, but where's the Handler class? That's where your remove method is :P In the previous episode (or earlier) he showed us two methods in the Handler class; one that adds object to the LinkedList and one that removes objects.
@cybercheese6948
9 жыл бұрын
here pastebin.com/TYmQA9dW
@naxaes7889
9 жыл бұрын
This should work: handler.removeObject(handler.object.get(0)); It removes the first object in the LinkedList. If you want to remove the second object you write: handler.removeObject(handler.object.get(1)); And so on...
@bigdirtygaming6429
9 жыл бұрын
Just gave you your 200th like awesome vids thank you so much !
@kingjulianxd8880
9 жыл бұрын
yes first
@kfcchrizminecraft186
9 жыл бұрын
Im getting an error for the snake tut you make in 2013, can you make a new tut? Thx!
@BeamPlays
9 жыл бұрын
:D
@flamme78420
8 жыл бұрын
For the health changing color part, I used "greenValue = 255 * health / 100;" So that the green is reduced as a percentage of the health, and I have found that setting the red to 150 instead of 75 creates some nicer colors.
@jilljessurun2897
2 жыл бұрын
nice one. I just did like if health lower than 50 go orange, lower than 20 go red. Just like pokemon xd
@louisedbrooke1189
8 жыл бұрын
Anyone getting the null point exception at level 2 make sure you have this line EXACTLY in your Spawn Class private Random r = new Random();
@MatthewGarciaMusic
8 жыл бұрын
+Louis Edbrooke yeah, i got that as well. thanks
@shamen.
6 жыл бұрын
I got that problem and what you said didn't work
@윤준식-o5l
5 жыл бұрын
You're my life saver
@dawnexplain3128
4 жыл бұрын
It still doesnt work for me ;-;
@rafalprusakiewicz9228
5 жыл бұрын
I have an issue where if I press too many keys at once (i think 3) and then press another button it won't work even if I let go of those 3 keys. It's probably a problem with the key handler. Is anybody else having this issue?
@othmanaljameel7024
8 жыл бұрын
i'm having a problem with making the level goes up + RealTutsGML the score is fine but i can't make the level increase.
@tomascanevaro4292
6 жыл бұрын
I took the liberty of adding music to the game by implementing this method in the Game class: private void music() { //Play music String songName = "Song_name_here.mp3"; //Replace it with your audio file String pathToMp3 = System.getProperty("user.dir") +"/"+ songName; BasicPlayer player = new BasicPlayer(); try { player.open(new URL("file:///" + pathToMp3)); player.play(); } catch (BasicPlayerException | MalformedURLException e) { e.printStackTrace(); } } with this imports: import java.net.MalformedURLException; import java.net.URL; import javazoom.jlgui.basicplayer.BasicPlayer; import javazoom.jlgui.basicplayer.BasicPlayerException; and the invoking it at the begging of the run method: music(); //Play song Aclarations: You do need to download the library, witch you will probably have to google. Also, it does make your console display a bunch of red messages before it starts displaying the FPS counter, and i don't know why, but it doesn't interfere with the program.
@plainplaying3761
3 жыл бұрын
Sometimes randomly I am getting the error: "Exception in thread "Thread-0" java.lang.NullPointerException: Cannot invoke "HUD.render(java.awt.Graphics)" because "this.hud" is null", i think that for some reason my render function is running somehow before the constructor, what am i doing wrong?
@swiftninjapro
6 жыл бұрын
to shorten the spawn class and made it easier to add new Enemys :D I added this just above the spawn tick method: private void summonWave(int Basic, int Fast) { for (int i = 0; i < Basic; i++) { handler.addObject(new BasicEnemy(r.nextInt(Main.WIDTH - 10), r.nextInt(Main.HEIGHT - 10), ID.Enemy1, handler)); } for (int i = 0; i < Fast; i++) { handler.addObject(new FastEnemy(r.nextInt(Main.WIDTH - 10), r.nextInt(Main.HEIGHT - 10), ID.Enemy2, handler)); } to add new levels, I now only have to do this: else if (hud.getLevel() == 3) { summonWave(4, 2); the numbers are the amount of each enemy this will spawn this would spawn in 4 BasicEnemys and 2 Fast Enemys on level 3 with this you only have to change the level number, and the number of Enemys you want to spawn :D
@jilljessurun2897
2 жыл бұрын
Hi, i have a question, hope that someone knows an answer. How do you solve the problem when you use velocity to move the object, the object keeps renderinng on old positions? When you remove the background and move the object you can see exactly what i mean. For small programs this aint a problem, but when you get like 100 objects in the screen the FPS keeps dropping to the point the program doesnt work anymore. Is there a way to first remove the rendering of the old positions of the object? Thanks in advance.
@konstandinosdimitriou2301
3 жыл бұрын
my game has lag and the player movement is terrible is ther anything i can do so it can run better i am on linux using intellijy .
@StefanBanu
9 жыл бұрын
Finally, glad you're back man. :)
@hutchza1776
9 жыл бұрын
For some reason I can't get the getter method to work in the Spawn class. Once I do hud.setLevel(hud.getLevel()+ 1); in the tick method the console gives me Exception in thread "Thread-3" java.lang.NullPointerException I don't know what to do! can someone plz help? p.s. i'm a noob
@rubydacherry4711
7 жыл бұрын
Same , help me someone please :(
@pugachan
6 жыл бұрын
on this method public Spawn(Handler handler, HUD hud){ this.handler = handler; this.hud = hud; } don't forget to declare this.hud = hud; I've got the same problem; =D
@jasonlong9929
7 жыл бұрын
Is there a way to do the addObject() method on a keyboard press.
@000MIIX
7 жыл бұрын
yes, if you go into your KeyInput class, you can add a if statement to add enemies. if (key == KeyEvent.VK_1) handler.addObject(new BasicEnemy(random.nextInt(Game.WIDTH -50), random.nextInt(Game.HEIGHT-50), ID.BasicEnemy,handler)); add it in either keyPressed or keyreleased dependent on how you'd like it to work.
@adriatomas4972
6 жыл бұрын
i do this: my setLevel(int score) every tick, inside function i got -> public void setLevel(int score) { level = this.getScore() % 1000 == 0 ? ++level : level; } i think i the same as your method but more simple (sorry for my english)
@braderbell6814
4 жыл бұрын
just gonna say it to feel better about myself. but couldnt you have done the levels in way fewer lines like this: if (score>level*1000) level++;
@asutoshvariar
4 жыл бұрын
Next: Making a player that appears and disappears very quickly at random times at the edge of the player's vision.
Пікірлер: 223