Random game...

Feel free to showcase your own projects!
Post Reply
User avatar
popcan12
Posts: 592
Joined: 10 Feb 2012, 02:30

Post » 30 Jul 2013, 05:44

Ok... so I have this java code, but I want to make it into a java application, how would I do that?

Code: Select all

import java.util.Random;
import java.util.Scanner;


public class Main 
{
public static void main(String[] args)
{
 //Something
	Random random = new Random();
	
	//Scanner for testing
  Scanner lost = new Scanner(System.in);	
  
  int userChoice, meow;
  
  
  System.out.println("Your move sonny; 1,2,3");
  userChoice = lost.nextInt();
  meow = random.nextInt();
 //Being a smartass
  
  if (userChoice < 0) 
  {
	  System.out.println("I'm sorry to say, but you actually need to pick between the 3 numbers.");
      System.exit(0);
  }
  
	  if (userChoice > 3)
	  {
		  System.out.println("That's not one of the choices!");
      System.exit(0);
  }
{
   
   
   if (userChoice == meow);
   {
	   if (meow == userChoice)
   System.out.println("You got the same as meow");
   }
   if (userChoice >= 1);
   {
	   if (meow > userChoice)
	  System.out.println("You lose."); 
    }
   if (userChoice >= 1);
   {
	   if (meow < userChoice)
		   System.out.println("You win.");
   }
   
   {
   
   }
	
  lost.close();
}

}
}
Does anyone know how to make a window in Java, or could I easily convert this code into love2d?

User avatar
Mr.Q.Marx?
Posts: 849
Joined: 15 May 2012, 18:35

Post » 31 Jul 2013, 20:09

Get netbeans. (https://netbeans.org/)
New Project.
Copy and paste the code in.
Run the project.

Converting to love2d? So lua? Well it can be done but honestly with code that simple, just rewrite it.

User avatar
rokit
Posts: 2095
Joined: 03 Feb 2012, 00:47

Post » 27 Aug 2013, 20:22

If you ran that in netbeans or eclipse it would run in a console. So making it into a jar and running it would make it run in a console window. I assume you are trying to make it using GUI.

As for porting into love, I think you're thinking of lua since love doesn't have such a simple input system so porting it into lua would be more reasonable since input is way easier.

Or the best option in my opinion, get LoveFrames here: http://love2d.org/forums/viewtopic.php?f=5&t=9116
It has text boxes for input and looks nice. But basic Love2D knowledge is needed. So for now I suggest compiling it to a jar and run it from a console.

Post Reply