Java 2D OpenGL RPG Tutorial 3: Creating Items

preview_player
Показать описание
In this video we create a new leveling algorithm and create basic items
Рекомендации по теме
Комментарии
Автор

I just read a lot of books on the subject and seen a lot of code. I pick up the good stuff quite fast and it doesn't hurt to make your tutorials even better :)

tabularasa
Автор

I found the algorithm to be the most interesting part of the video. I love algorithms <3

jrinkthedew
Автор

It's the reason they invented pair programming :) (btw love the series, I learned a lot too)

tabularasa
Автор

Dear Benny, don't know if you still read these comments, but I would like to discuss your leveling algorithm. After grabbing my graphical calculator, using your functions and analysing some of its outcomes (very interesting indeed!), I realised that a more "readable" and perhaps even "easier" implementation would be this:

int lvl = 0;
float x = xp;
float nextlvlneeded = 100;
while ( x > 0 ){
    x -= nextlvlneeded;
    nextlvl += 100;
    lvl++;
}
return lvl;

In essence, you grab the xp, and simply start subtracting more and more from it: for the first level, subtract 100xp, and automatically lvl1 (as the while-loop always runs once at least). If you have more than 100xp, the while loop runs again - so you're lvl2, and it subtracts this time 200xp. If you have more than 300xp (xp-100-200 > 0), again: (xp-100-200-300 > 0),  etc.

As "nextlvlneeded" constantly increases with 100:
In this way: LVL1-(upto)100xp, LVL2-(upto)100+200=300xp, LVL3-(upto)300+300=600xp, LVL4-(upto)600+400=1000xp. 

Much like the function results from your (complex) algorithm. 

Before I end this message, I would like to thank you for your outstanding, sophisticated, funny and very, very thought-provoking free series of programming! Thus far I am thoroughly enjoying all your series.

All the best, and you earned a sub of course :)

Afterliv
Автор

To expand on this, a few months back I hit this problem and solved it via pixel-based collision detection. Even using accurate AABB's I noticed signifigant performance decreases.

It's about as exact as you can get, but sometimes you just have to sacrifice realistic game mechanics for PLAYABILITY :D

Nocare
Автор

Also thank you for the tutorials they are the best! Keep up the good work

casvanmarcel
Автор

Could you make the video where you explain the algorithm you came up with(and how)? Really interested in that :-)
Keep up the good work :-)

Naxanria
Автор

One suggestion for the Item class (this is before watching the full video because if I don't say it now, I'll forget), but I think you should make a protected int id, so that it's easier to keep track of which item is which. I'm not saying you have to, I just think it would be a bet better for organization

SergeantBalthazar
Автор

a= Math.sqrt(243 * x* x + 4050 *x + 17500)
243 is an integer so the entire calculation between parentheses is calculated in integers. After that it is promoted to a double and the sqrt taken. it should've been 243d
same for c= (3*x +25) /25 the 3 makes it that the calculation is done in integers and the value is only promoted to a double when assigning the value to c.

tabularasa
Автор

this is coming along nicely.
do you think by the end we'll have the next elder scrolls game? ;)

SamBrev
Автор

Instead of having a variable keeping track of the type it might be better to use a method getType() that returns a constant, that way you never have to initialize it.

The init function didn't complain about the missing @Override is because you didn't override it, you overloaded it.

tabularasa
Автор

Hey benny, I'm loving your videos. I'm only here in the series, but I noticed something.. you never clear the "remove" ArrayList after removing those objects from the main 'object' ArrayList. Hopefully I'll see that change in one of the remaining videos in the series ;)

BetterCoder
Автор

ya i learned alot watching how you developed that algorithm, very interesting. Question though about something else. I know that for just the testing part of the game you are using rectangles to detect the collisions, but eventually when my sprite isnt a rectangle and its an image, how will the physics class know if they itresect since intersects is a Rectangle class method?

anthonyb
Автор

I knew I wasn't gonna be the only one haha

hobblesu
Автор

Hi Benny, I was wondering what do u do if you need to have several npcs know about other thing? Would you pass in like every game object into them or is there a more efficient way?

OCoptimusconvoy
Автор

These videos are great!  I had the same problem with this video and pong; when you implement collisions between objects, i always get an error compiling.  could you possibly post what all source code looks like after the videos, so we dont get stuck?

TehBigGrabowski
Автор

Is there any benefit to using constants rather than variables?

andrzejgieralt
Автор

(d/3)*2. that's all you had to do. but yours looks cooler.

TheScriptPunk
Автор

Hey could you help me a little bit? After adding the new update code to the game.java im getting Exception in thread "main" and i dont know why.

PoWR
Автор

@thebennybox

I made game accesible in the main.java class and added a public static method getGame() which returns the game object. Everytime I need access to the game I simply call Core.getGame() (I renamed Main.java to Core.java because reasons)

Does that strike you as an efficient way to make the Game object visible to every class/method that needs it?

Fangornmmc