Well I'll dive into that i guess.
--- Update ---
Do you have a good link as for an explantion of how getClass().getResource(). is meant to be used?
--- Update ---
Okay figured it out,...
Type: Posts; User: The_pizzaguy
Well I'll dive into that i guess.
--- Update ---
Do you have a good link as for an explantion of how getClass().getResource(). is meant to be used?
--- Update ---
Okay figured it out,...
So i am making a basic game and i am loading the images as such :
try {
background = ImageIO.read(new File(res/textures/bg.jpg"));...
I have made an autoclicker. But i wonder if i made it correctly.
I am not sure where to post this on the forum but i just post it here.
Here is the link to the video i made of it :**Link Removed**
There you will find the download link of the jar and the source...
I have an explaination for your code.
Your code makes sqaures indeed but what happens is that when the last square is made(i = 7 ; 7 * 7= 49) the loop will stop because j is over 40.
If you want to...
I found a fix. What i did is i made 2 more array list for the dead aliens and bullets to store the index into. Afther the loops have ended i made 2 extra loops to delete the aliens and bullets.
...
Thanks XD
I hadnt thought of that yet thank you
When a bullit bullit hits a alien it creates this error :
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at...
You cant use "void int function_name(){}" because you have two return types and every methode only can have one.
Here some examples(these are from a entitybase class but the prisiple is the same)...
You are actaly not creating a window. You extend the class with JFrame. I find this really annoying, i always import it and use it as a instance, wich makes you more capable of making more windows at...
because you exit that "fuck" methode and it continues in the main methode. Return exits out of a methode and break breaks out of loops and if statments
I think so but searching up tutorials is allways good
If you are already started with java its better to stick with it. Otherwise you might get confused between diffrent langauges. Java is easier to make games in then C++, C++ is really hard to learn....
If you want to learn about collition, look into the Rectangle clas. And for more gameprograming tutorials look at:
The Cherno - YouTube
He has some really good 2D game programming tutorials.
So i switched the for loops arround and that was it and now it works.
Here is the code if anyone wants it.
private void colision() {
if (aliens.size() >= 1 && bullets.size() >= 1) {...
i havent tried that yet but i dont think it will make a diffrence
but ill do that now
--- Update ---
well i initilasid the bullits earlier but what happens is that the were shot and afther...
as said in the top its
at com.spaceinvader.Main.colision(Main.java:172)
line 172 thus
if (bullets.get(i).getBounds().intersects(aliens.get(i2).getBounds())) {
in the colision methode
it...
So i am recreating space invaders to teach myself some game programming.
For the first time i have started to use ArrayLists.
But every time i run it i get an java.lang.IndexOutOfBoundsException...
Its easy, you can make a variable of the main class in the other wher its calculated with
public static Main main = new Main();
With this you can use the main for alot of things....
Wow this code has so many errors in it. Nearly 2/3 of the code has errors.
I am just advising you to look at your code and take out any syntax errors like Strarstreak pointed out, also these...
I wouldnt know how to do it else, could you give me an example then? XD
It is just an example, and the while loop used in my last comment could be the main update loop.
If that loop is running it will auto update the code to uppercase.
Still java is pretty good and for a wider audionce because of its multi platform.
And its really good for web applications because they are easily intergrated.
The benefit of java is:
-Could be easy implemented in webpage;
-Fast compilation
-No istalation and thus fast starting up
-mutiplatform
but general C++ and C# are faster, this is because of ...
you have to make a JFrame first with a text field
If you want the text automaticly changed to uppercase.
you should put this code in a loop(could be in the main).
String text;
while(){
...