Tag Info

Hot answers tagged

10

The PNG files are small because they are compressed. When the images are loaded into memory they are uncompressed and therefore take up more space.


5

As others have said, the first step is separating logic that's shared from logic that's not. While it's great to draw that line wherever it's clear, your addendum illustrates that sometimes you don't have a clean line to split the code down. So, how do we solve cases where the client and server want to do semantically the same thing (play a sound), but take ...


3

Before addressing the specifics of your question, I do want to point out that I disagree with your approach to your inheritance model. A Game generally does not implement a Scene but instead a Game consists of one or more active Scenes that are being rendered and updated in a main loop. It's important to think about whether a class relationship can be ...


3

why not create a list of enemies in the level so the draw becomes: List<GenericEnemy> enemies;//filled during construction Render(){ //Render elements common to all levels draw(background); draw(playerSprite); for(GenericEnemy enemy : enemies) { draw(enemy); } } where GenericEnemy is a superclass of all enemy ...


2

You're wasting CPU cycles. That means lower battery time on notebooks, tablets and phones, higher electricity bills, more heat generated by the machine, noisier fans. Also, you may be eating cycles from other important system processes (e.g. the window server could become jerky), which could then affect gameplay. Some system schedulers on today's pre-emptive ...


2

This is an old question, so I'm guessing that tom37 may have moved on by now, but I think I have an answer for anyone else with the same problem. For reference, here is a view of a surface grid using a perspective camera. Now let's say that we want to render a portion of this current view, but to the entire screen. Let's render the top-left quarter of ...


2

Extract any shared code to a library which you maintain separately. Then implement your client and server as a separate applications which implement anything specific themselves and reference the library for any shared functionality.


1

Your map[][] is static so the three objects (layers) will access the same map (and overwrite it). You should make it nonstatic to allow each object to have it's own. Secondly the fileParser() method is private so you will have to either make it public or call it inside the class.


1

You are loading textures and models from files on disk, that's your problem. File I/O is very expensive and should be avoided as much as possible. Preload your model and whenever you need to add a badger, clone one from the preloaded and just alter the properties that you need to.


1

You have a translate function outside of the if statement. . . . if(!turn){ bug.translate(v.x * Gdx.graphics.getDeltaTime(), v.y * Gdx.graphics.getDeltaTime()); } else{ bug.translate(-(v.x * Gdx.graphics.getDeltaTime()), -(v.y * Gdx.graphics.getDeltaTime())); } bug.draw(spriteBatch); ...


1

The cleanest way is to create a "core" project that includes shared game code. You can use either interfaces or abstract classes to prepare your game code there and use inheritance [1] to extend/implement these classes in either the server or client side. That way you do not need any if statements to distinguish between client and server code. You should ...


1

It looks like you are first rendering the buffered image with bilinear interpolation and the result is later stretched with nearest neighbor filtering. It's hard to say without seeing the rest of the rendering code. When I copied your code and used it to fill the background of a JFrame, I got either large solid color quads or fully smooth image depending ...


1

Most likely it is antialiasing the image, in an attempt to avoid looking pixelated. If you have a Graphics2D called g2, then you can modify the settings: g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); The abstract Graphics class does not have this method, but the Graphics object you have ...


1

Can't speak to the exact implementation details (and if I could it would be off-topic), but here's some obvious ingredients to put together: The camera is using an orthographic projection. You can tell this because a vertical wall is exactly vertical on-screen no matter where it is — if the camera were perspective then they would be "leaning outward" from ...



Only top voted, non community-wiki answers of a minimum length are eligible