Best way to make .io style game in java? - java

So I have come up with an idea for a .io style game using java. (I know it isn't actually a .io, that's just the domain that is commonly used.) I would like to start out by making a grid and I have tried with JFrame and JPanel etc but I think im barking up the wrong tree...
Anyone got any useful advice in terms of making a game "space"/map? I'm a fair beginner but I'd be OK with a not-too-in-depth explanation, just want a a good point in the right direction. And yes, I know the IMMENSE amount of work that goes into the multiplayer networking and everything else like that but I just want to get the game up and running as a single player to start with.
I think other people would appreciate a decent answer to this question aswell...
Thanks!

Can you use JavaFX? They have a GridPane which might be what you want. If all you want is a grid-like background and not an actual grid like slither.io then I believe you can just draw an image to background. You can (should?) also use OpenGL. If you plan to use OpenGL then you can use LWJGL or a game engine like libgdx

You would have a much easier time doing this in JavaScript using an HTML5 canvas. You could even use the Socket.io framework for handling all the networking. There's tons of tutorials for that stuff on YouTube, and switching to JavaScript is stress-free. I learned the general syntax in under an hour after coming from Java/C++.

Related

Is there a Java counterpart for Spritekit's SKActions(moveBy)?

I am working on converting some of my games to android after already publishing them to the IOS App store. I wanted to add a little motion to the objects on the screen. In Spritekit, you can simply use the following to move a node a certain length:
Node.run(SKAction.move(by: CGVector(x,y), duration: time))
This is very useful for giving motion to stuff on the screen and wanted to replicate it in Java. Does anyone know how this can be done?
Unfortunately, it is not that easy to move objects in Android.
There is some difference in iOS and Android, where iOS provides easy to use framework, Android doesn't have any easy to use native framework.
Now how to do it, in Android?
First let's learn some basics:-
iOS has SpriteKit, Android has Canvas
SpriteKit can use concept of Node to display object on screen.
Canvas uses bitmaps to draw objects on screen.
Now, it is too big of a topic to cover on Stackoverflow, but the general things, we need to do is:-
Draw objects on screen, where they should have been initially
Then we have to setup game environment is such a way, that the game runs in a while loop, and which should atleast give user, 60 FPS.
Then add the move object logic, inside the while loop. Thus, giving the user, the illusion that the object moved (2, 6) position in 10 seconds.
I would literally just show you the code, which does that https://bitbucket.org/jenelleteaches/android2d-pongclone/src/master/MainActivity.java
And would recommend reading this book, before moving into 2d game development in Andorid :- Android Game Programming by Example. This is published by Packt

creating timeline-based editing gui in java

I want to create a timeline-based editing GUI in java - in the style of a video-editing software (such as adobe premiere for example). Below is an image, how I have the GUI in mind (sorry for not including it directly - as a new user that feature is disabled):
Whats currently implemented is just the timeline-slider at the top (with JSlider) - all the rest is just made up with Photoshop (also the black-line that goes down from the slider, through the layers).
Now my question is not very specific, I just wanted to get some input how I could implement the rest as nice as possible. To be a little bit more precise, I would appreciate hints to the following topics very much:
How to organize the whole gui - concerning the time indicator-line
which goes from the top to the bottom through all the layers?
How to visualize the waveform, are there good (and free) packages
that can be used? (audio files are either MP3 or WAV)
Which element to use for the text-segment layers (they should be draggable & droppable somehow) -> JLabels, JButtons, how to best solve the drag-n-drop feature?
You see I have still some work ahead of me, any good advice or point to the right direction would be very kind!
For the waveform issue you could take a look to this question and the accepted answer. The class creates a PNG image file, but you should be able, instead of saving the image, just display it in your programm.
The drag n' drop thing is well explained in this tutorial by Oracle.

Drag and Drop and identify locations with java

I'm trying to do something quite simple, but I'm having a hard time finding good examples on the net to what I want specifically.
I'd like to somehing very similer to what it's here:
Dao
It's a simple game called DAO and I just need to have a background image with 16 squares (4x4) and drag and drop the images (pieces) on each square to the others. I'm developing the interface using swing and I simply want to know a good place to find tutorials for such implementations or a simple suggestion on how to do it.
Thanks in advance
Shameless plug:
have a look at my simple example via my google project
http://code.google.com/p/jchronos/
There is code to drag list item across list boxes. Same should be applicable to JLabel
Look at sources
http://code.google.com/p/jchronos/source/browse/trunk/src/org/jchronos/ui/QuadrantPanel.java
http://code.google.com/p/jchronos/source/browse/trunk/src/org/jchronos/ui/ArrayListTransferHandler.java

WorldWind: 3D-Objects - Sphere for Moon, how?

I asked this question in an Nasa WorldWind forum but haven't got a reply yet http://forum.worldwindcentral.com/showthread.php?t=24428
So, perhaps you could help me :).
I'm still playing around with WWJ and what you posted here http://forum.worldwindcentral.com/showthread.php?t=24318 THX!
currently I'm trying to add different layers, so that I can add several polylines and can clear them, so that I can "let them grow in realtime".
but my aim is still to implement at least basic represantations of moon and other celestial bodies and the spacecraft.
I want to use WWJ for a lunar mission and I'm simulating a n-body problem and I would like to have representations of all bodies.
it doesn't matter when there are just spheres, but they have to be at least the size and te position of the body simulated.
how can I chieve this? I couldn't find this in the wiki.
the uber-thing would be to use WW's moon model and place it accordingly, but just a sphere painted grey would be okay :).
(that's why I asked for a solar view in another thread :))
Andreas
Apologies in advance if you already know about these, I've never used WWJ myself -- though I may have to play with it a bit when I get home tonight.
Sun has a page on its website (link) about getting started using WorldWind in your apps. And the WorldWind people have a wiki that contains a developer FAQ, among other things.

What is the best way to create a smooth notification window in Java?

...similar to those produced by email clients like thunderbird or outlook, sliding up or fading in from the tray.
The simple popup: Look at http://jtoaster.sourceforge.net/
For the fancy stuff look at what Java 2D can do:
http://java.sun.com/products/java-media/2D/samples/java2demo/Java2Demo.html
Check Composite -> Composite FadeAnim.
What are your notifications for? Is it for a program that already exists, or are you writing a new application?
I ask because Adobe AIR has some functionality for doing this sort of thing, either as a Flex based application, or an AIR application written in HTML/JS. But, you wouldn't use AIR unless this is something you were building from the ground up.
Swing's Timer class (http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html) can be used for rudimentary animation - just use the timer to update the location of the panel containing your content.
I attended a JavaOne session last year where they did some pretty slick stuff with this.
Slides : http://progx.org/users/Gfx/FilthierRicherClientier.pdf
pay special attention to page 29 and on.
And here's a website from the same folks, but with more code and screenshots, etc...
http://today.java.net/pub/a/today/2007/10/23/create-moving-experiences-with-animated-transitions.html
The end result of all of this was very, very slick.

Categories

Resources