3D Game Programming - Episode 6 - Performance Boosting

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

Welcome to a series of videos where we will create a 3D game (probably a first person shooter) from scratch, using just the included libraries in Java 1.6. If you have any questions or problems, leave a comment or send me a message, or tweet at me.

In this tutorial:
How to boost performance
How to smart code

Tell me if you want more!

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

you can just do this.height and this.width, since those are set to the display width and height.

nulithetzros
Автор

you don't need to create a display object just call width and height that's already in the render class because you set that class's width and height to the w and h of the frame when you call the constructor

kilpatrickdeonta
Автор

I can't explain how much I love this series.

Fusdew
Автор

Instead of creating an instance of the class "Display" in "Screen" to use the width and height values, just use the 'width' and 'height' from the screen class itself. They get set to the same values as the ones on "Display" in its constructor.

zeluisping
Автор

I don't know if someone has answered you yet, or if TheCherno has gone over this, but I'll do my best to explain what's going on. Basically what the math is doing is making the x-values and y-values of the square increase and decrease continuously from -1 to 1. If you graph a Sine(x) or Cosine(x) wave you can see the wave going from 1 to -1. Then he multiplied it by 100(and other numbers) to make the circle it makes bigger. I'd try going more in depth, but I'm only allowed 500 characters.

davidlamar
Автор

Headsup guys at about 3:33 he talks about creating a display reference when it isn't needed, just change the numbers in the if statements to width and height properly and it works fine

TheArcher
Автор

You didn't need to do "Display.height" or anything to fix the border issue with the square - you could just have done this.height / this.width

real_evin
Автор

thank you for taking the time to reset after the mishap. Your time is appreciated!

PowrGaming
Автор

Firstly, thank you for this series! I've been following along and I've been able to get something that actually renders properly without any issues.

I also just want to point out something related to the fix; the reason why updating the display size doesn't change the render size was because in the Screen.java, render is being created with a fixed size of 256. Changing it to "test = new Render(width, height);" fixes the problem. (Though, chances are that you've already caught that problem in a later episode.)

Joshulties
Автор

I want to learn Java programming so bad but I find it confusing a lot. The tutorials are working but I feel like I'm not understanding it like I should be. But still great videos!

TheMinecraftGuy
Автор

If you make both lines equal
(int) + i * 500) % 2000.0 / 2000 * Math.PI * 2) * 200);
It makes a really cool effect!

lojana
Автор

For the display limiting bug, the "fix" couldn't have been more wrong. Eclipse has warnings for a reason! Firstly, you wouldn't need an instance of the Display class as the WIDTH and HEIGHT variables were static, meaning they are accessible from any class. Secondly, the "instance" of Display shown in this video was not initialized, so it would not work if it was not static. Thirdly, a much simpler fix would be to use the "width" and "height" variables in the Screen class - they were already set.

daviga
Автор

You don't need an instance of Display, to access the public static constant. Being static, it can be accessed statically (which is basically the point). So all you need to do is write Display.HEIGHT or Display.WIDTH, where "Display" is the Class Name (not an instance name).
Just a small heads-up from me. Besides that, nice job.

NooB
Автор

comparing alpha to 0 is checking if the pixel is to be black or not. When you switch the sign of the comparison operator, you are essentially asking which values are negative. But since the mapping is from 0 to 256, you will find that the condition applies to of the pixel values and, hence, the check is useless when checking for alpha<0

muzak
Автор

you already had the width and height variables in the display class set as static so you dont need to make an instance of display, you can just import it and do "Display.HEIGHT". thats the whole reason for having something be a static variable

Akylosauria
Автор

I also saw that by doing this, if you happen to have multiple Render classes to the same window, then each Render instance won't draw outside of its own bounds. Otherwise, by having the draw bounds as the size of the window, it will draw outside of itself on the screen. The only foreseeable issue with that, however, is if someone has the xOffset or yOffset move a section of the render class outside of the window. Then when it draws, it will crash. So the new object is needed, nonetheless. :P

ScipiPurr
Автор

Yan clearly said: If people are getting problems then they can use it.
It wasn't about learning, it was about there mistakes.

KingFaris
Автор

this.width and this.height makes much more sense to use. ( this.width/height comes from Display.width/height anyway ) There's no need to create a display object. Those values are static anyway, so if you wanted to use them you could just use Display.width/height

shinigami
Автор

I just changed the values in Render to Display.HEIGHT and Display.WIDTH since they are static, you don't need to instantiate an object of the class to access the static values.

Cheers!

JasonEwton
Автор

Do you even understand "your" code? The fix at the beginning of the video seems very wrong. You seem to use the render class for any kind of sizes (like the 256x256 random picture). So why do you use the display size as bounds for the coordinates in the draw method? It should just be bounded by the size of the instance of the object you are drawing on, which would be just this.width and this.height. 

Leif