• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Jiraya
      For a 2D game, does using a float2 for position increases performance in any way?
      I know that in the end the vertex shader will have to return a float4 anyway, but does using a float2 decreases the amount of data that will have to be sent from the CPU to the GPU?
    • By ThunderTwonk
      Hello everyone, I am working on a game idea and since I am still in the process of learning C# and the features available in unity I was hoping some of you might be able to offer me a little insight on things in general for getting started.
      I guess the basic components of what I'm wanting to create would be a Multi-levels management/city builder/rpg.
      The goal is to provide a framework for players to interact with, build in and affect the world both from a 3rd person action RPG as well as a zoomed out 4x style view (This would be something unlocked through gameplay)
      As for my questions go I was wondering if anyone had resources that could help me learn.  I've been on youtube as well as enrolled in an online course for basic unity and C# and will continue those but if anyone has any words of advice, a place that has good information and tutorials etc.
      Thanks for your time.
    • By INFRA
      SCAN. DRILL. SURVIVE.   ISOLATED Release in May 1st 2018   https://store.steampowered.com/app/805950/Isolated/   A game by Jérémie Bertrand Music & Sound Design by Pierrick Querolle *** Our solar system has been invaded by strangers. For the purpose of a possible negotiation, a team of astronauts is sent to the moon. Alas, they are shot before even arriving on the scene. Only one astronaut survives the crash and his only goal will be to go home...   GAMEPLAY   Shoot enemy ships to avoid being invaded. Be precise in your movements, because it's better to lose a bit of life at the top than to lose it all at the bottom. Take out your drill to destroy the stones in your path. Validate your identity to cross the different laboratories. Reach the flag before losing your three lives.   And all that... at the same time! Will you be able to go home? If the answer is yes, how long will it take?
    • By Captain Jack
      Two questions: I am trying to rotate chroma in YUV colour space by separating each of the components and applying the following formula.
      int Ut = ((U-128) * cos(hue[H]) + (V-128) * sin(hue[H])) + 128; int Vt = ((V-128) * cos(hue[H]) - (U-128) * sin(hue[H])) + 128; ...where hue[H] is an array of rotation angles between 0.0 and 360.0.
      This seems to work OK but is dog slow. Is there a way to speed this up by converting to integer only calculation and doing away with cosine and sinus? 
      Second, when doing conversion between YUV and RGB, it seems that luma is also affected after rotation. To demonstrate what I mean, I am randomly rotating each line's chroma. The process is:
      Convert from RGB to YUV > rotate chroma > convert to RGB.

      Top left is the original image, the two images on the right are U and V and the bottom left is the luma. As you can see, it seems to have some artefacts from rotation. Is there a way to avoid this?
    • By deadless games
      i'm am looking for volunteers with little or no experience to help with music and graphic design.
      i was thinking of making a platformer game by myself to get into programming but struggled to make music and do Character design
      you PC doesn't need to be amazing,need to be willing to spend time doing your role,
      if you are interested please contact me with one of the means below.
      email deadlessgames@gmail.com
      discord xwolf572#6974
  • Advertisement
  • Advertisement

how to make game in java swing

Recommended Posts

Hi everyone.

My name is Sang and I am a student in primary school. I studied Java and  i am really like it.

and now I want to learn make game a game use Java in Java Swing. Would you like give me some websites teach make game java for begginers, please?

Thank you very much!

Share this post

Link to post
Share on other sites

Java, in general, is not well suited for game development (server code aside), specially Swing. You can do simple games with that, but it lacks many usefull things for games, such as joystick support and hardware acceleration.

If you really want to use Java, consider using better suited libraries like libGDX.

For Swing, check something like http://zetcode.com/tutorials/javagamestutorial/. Many concepts like game loops, state machines and collisions are applicable, so you can look for these, even if not in Java, and translate them as needed.

Share this post

Link to post
Share on other sites

Start with really simple games like hangman. Tictactoe for 2 players is easy too, quite more difficult is tictactoe if the computer playes one side!

With these games you don't need a graphical interface, you can just use standard input and output from the terminal (also known as console). Eg inspired from https://stackoverflow.com/a/5488107 :

import java.util.Scanner;

public class CopyTerminal {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String line = "";
        while (!line.startsWith("quit") && s.hasNextLine()) {
            line = s.nextLine();

Instead of merely printing the read line, check if the user typed something you understand by examining the 'line' variable, and process that input. update the game data, and print the new situation using System.out.println calls.

It may seem a bit silly to start here, but using the terminal is an easy and quick way to display information, I use it every day. Just printing a bunch of text lines is much simpler than displaying it in a graphical way. It allows you to quickly try things, and concentrate on the actual game rather than get distracted by big complicated gui stuff that merely just displays some information.


For swing, I would advise to first do a normal swing tutorial. You may find however it is quite oriented at normal gui (menu-bar, drop-down, buttons, labels, popup windows, hovers, etc) as you see in every-day programs, and not so much aimed at displaying loads of nice splashy graphics and cool sound-effects, as you tend to have in a game.

This is why people here use specialized game libraries like libgdx. Like swing it provides functionality for display and keyboard interaction, but also for displaying lots of graphics, and other things you may need in a game, like sound, joystick support etc.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement