Blue Source code

This is the place to post your own creative works for other to play or give feedback on!
Forum rules
This forum is for posting and collaborating upon third party work. Please do not post request-threads, and avoid posting artwork that is not your own unless it is being used as a reference.

Blue Source code

Postby BlueLight » Tue Sep 04, 2012 1:25 pm

Hello, i'm BlueLight and i'm a Java Programmer on this forum.

I've just spent half the night programming and decided to start sharing my little programs with the world. These programs might be something as stupid as a test program to figure out if an array starts at 1 or 0(it's starts at 0 by the way!). I will not hold my self up to a quality standard on anything share here nor assurances that it will work at all. Basically, it's here just because and it might not work.

if I put something in this thread, it's unlikely to work with out you having to compile it. Learn how to compile the programs yourself if you wish to try them out.
If you use a program called eclipse, make a new workspace, then new java project, then move the files over to the java project folder and refresh eclipse file; you should be able to run the program.

You are allowed to modify, take, or base your software off mine snippets of code; however, you must have a few lines of code in each file of yours that uses mine that basically says part of the code was created by me. I'm not to worried if your using this for personal use only, however anything else i would like the below comment in your class file. Note for people using my code who are taking java classes. under most codes of conduct for colleges, you are not allowed to use my code unless you cite it and if you do that then you risk losing points.

Code: Select All Code
/**
 *
 * @author BlueLight
 * @author Jordan C.D
 */


[link=Tic Tac Toe] http://docs.oracle.com/javase/tutorial/ ... ialog.html[/link]
Last edited by BlueLight on Sun Jul 14, 2013 8:17 am, edited 13 times in total.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

Re: Blue Source (cheap games @ best)

Postby BlueLight » Tue Sep 04, 2012 1:25 pm

Place holder for minor software
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

Re: Blue Source (cheap games @ best)

Postby BlueLight » Tue Sep 04, 2012 1:29 pm

The great old game of Tic Tac Toe. Such a wonderful game. i decided to remake it in java for all to roll their eyes at.

This is officially a working and a complete game but it doesn't have a normal GUI so your going to have to use the console. It is working and you can play yourself or someone else.


Code: Select All Code
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author BlueLight
 * @author Jordan C.D
 */
public class TicTacToeMain{
   GUI gui;
   
   boolean turn = true; //Which players turn it is. Should change this to byte.
   final static byte player1 = (byte)1;
   final static byte player2 = (byte)2;
   byte[][] board = new byte[3][3]; // The playing field. [Y0][X0]
   byte lineLength = 3;
   boolean replace = false;
   public static void main(String[] args){
      new TicTacToeMain();
   }
   TicTacToeMain(){
      
      gui = new GUI(this);
      
      for(int y = 0; y < this.board.length; y = y + 1){
         for(int x = 0; x < this.board.length;x = x + 1){
            this.board[y][x] = (byte)0;
         }
      }

   }
   public boolean moveMade(int y, int x) {
      byte player = 0;
      if( turn){player = player1;}
      if(!turn){player = player2;}
      System.out.println("Int Y = "+ y+"| Int X = "+ x +"| Player is "+ player);
      return this.moveMade(y, x, player);
   }
   public boolean moveMade(int y, int x, int player){
      return this.moveMade(y, x, (byte)player);
   }
   public boolean moveMade(int y, int x, byte player){
      boolean possible = false;
      System.out.println(this.board[y][x]);
      if((replace==false && this.board[y][x] == (byte)0) ||replace==true ){
         
         possible = true;
         this.board[y][x] = player; // this changes a value on the board.
         
         refreshScreen();
         if(!this.checkSquare(y, x)){this.turn = !turn;}
         else { gameWon();}
      }
      return possible;
   }
   private void gameWon() {
      String winner = "Player ";
      if(this.turn){winner = winner+"1";}
      else {winner = winner+"2";}
      
      System.out.println("____________________________________________________________");
      System.out.println(winner+" has beaten the other player(s) and claim victory!");
      System.out.println("____________________________________________________________");
   
         JOptionPane.showMessageDialog(new JFrame(),
                winner+" has beaten the other player(s) and claim victory!",
                "Winner",
                JOptionPane.INFORMATION_MESSAGE);
   
   }
   public boolean checkSquare(int y, int x){
      boolean win = false;
      
      //these if statements check to make sure going across, that there isn't any 3 tiles in a row starting from x = 0 and ending at x = 2
      if (board[0][0] == board[y][x] && board[0][1] == board[y][x] && board[0][2] == board[y][x]){
         win = true;
         System.out.println("!Across top worked\n You've won");
      }
      else{System.out.println("Across top failed");}
      if (board[1][0] == board[y][x] && board[1][1] == board[y][x] && board[1][2] == board[y][x]){
         win = true;
         System.out.println("!Across mid worked\n You've won");
      }
      else{System.out.println("Across mid failed");}
      if (board[2][0] == board[y][x] && board[2][1] == board[y][x] && board[2][2] == board[y][x]){
         win = true;
         System.out.println("!Across bottom worked\n You've won");
      }
      else{System.out.println("Across bottom failed");}

      
      if (board[0][0] == board[y][x] && board[1][0] == board[y][x] && board[2][0] == board[y][x]){
         win = true;
         System.out.println("!Top-to-bot Left worked\n You've won");
      }
      else{System.out.println("Top-to-bot Left failed");}
      if (board[0][1] == board[y][x] && board[1][1] == board[y][x] && board[2][1] == board[y][x]){
         win = true;
         System.out.println("!Top-to-bot Mid worked\n You've won");
      }
      else{System.out.println("Top-to-bot Mid failed");}
      if (board[0][2] == board[y][x] && board[1][2] == board[y][x] && board[2][2] == board[y][x]){
         win = true;
         System.out.println("!Top-to-bot Right worked\n You've won");
      }
      else{System.out.println("Top-to-bot Right failed");}

      
      if (board[0][0] == board[y][x] && board[1][1] == board[y][x] && board[2][2] == board[y][x]){
         win = true;
         System.out.println("!Diagonal upper-right worked\n You've won");
      }
      else{System.out.println("Diagonal upper-right failed");}
      if (board[0][2] == board[y][x] && board[1][1] == board[y][x] && board[2][0] == board[y][x]){
         win = true;
         System.out.println("!Diagonal upper-left worked\n You've won");
      }
      else{System.out.println("Diagonal upper-left failed");}
         
         return win;
   }
   public void refreshScreen(){
      for(int i = 0; i < this.board.length; i = i +1 ){
         System.out.println("|"+board[i][0]+"|"+board[i][1]+"|"+board[i][2]+"|");
      }
      
      System.out.println("\n turn complete, now it's " + this.turn +" turn to play");
   }

}


Code: Select All Code
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Scanner;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
   
/**
 *
 * @author BlueLight
 * @author Jordan C.D
 */

public class GUI extends JFrame implements ActionListener{
   TicTacToeMain ticTacToeMain;
   JButton[][] button = new JButton[3][3];
   GUI(TicTacToeMain TickTakToeMain){
      this.ticTacToeMain = TickTakToeMain;
      this.setLayout(new GridLayout(3,3));
      for(int y = 0; y < this.button.length; y = y+1){
         for(int x = 0; x < this.button[y].length; x=x+1){
            this.button[y][x]= new JButton(y+" "+x);
            JButton button = this.button[y][x];
            
            this.add(button);
            button.addActionListener(this);
         }
      }
//      this.button[0][0].setText("fail");
      
      this.setVisible(true);
      this.pack();
   }
   public void actionPerformed(ActionEvent event) {
      Scanner scan = new Scanner(event.getActionCommand());
      int y = scan.nextInt();
      int x = scan.nextInt();
      
      System.out.println("Int Y ="+ y+"|Int X = "+x);
      if(ticTacToeMain.moveMade(y, x)==false){error();}
   }
   private void error() {
      JOptionPane.showMessageDialog(this,
             "I am sorry but there was a problem with your move. Maybe some one already played here?",
             "Move error.",
             JOptionPane.ERROR_MESSAGE);
   }
}

User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

HOORAY!

Postby DeadlyAlias » Tue Sep 04, 2012 4:12 pm

I have been trying to get into Java for a while, and I learn best by dissecting and experimenting with other people's code. If you posted a program that can read and write in a .txt file, I would credit you in every game I ever developed in Java.

I can't believe I missed this before, this is exactly what I was looking for.
User avatar
DeadlyAlias
 
Joined: Fri Aug 19, 2011 5:08 pm

Re: Blue Source code *SOON* (1 game complete, 1 update)

Postby BlueLight » Thu Dec 27, 2012 10:58 pm

I'm working on a new game. It's a basic hunting game but I don't know if i will finish it.
Anyways i'll keep everyone updated on the developments of this game, because i think you care.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

Re: Blue Source code (1 game complete, 1 update, WIP 1)

Postby BlueLight » Mon Jan 14, 2013 11:34 am

i start yet another project. However this one i think will go much quicker since the basic design is something i've done before. It should be done in a day or two and then i'm dropping the project. Isn't a big project and i'm mostly reusing old code and modifying it as i go.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

Re: Blue Source code (1 game complete, 1 update, WIP 1)

Postby BlueLight » Fri Jan 25, 2013 9:19 am

Ah the life of a college student.... Let me tell you, it sucks, it's fun, and it's needed. I haven't really had the energy to program as of late and when i do i'm procrasting and trying to do anything with in my power to keep from studying.
Anyways i've slept already and it's 12 AM. I should be studying for my math test today but i think i'll get some progress done on my program before the weekend. Nothing shockingly new for me in this but i haven't really programmed much as of late so hopeful this program will help jump start me again.

There seems to be a bug in my program so i can't show any screen shots of what little i have. This is kinda of a tip of the hat to another program in the forums than a game.

Edit
Fixed a bug so now it really does work. I'll add controls later today followed by maybe doing other entities. Anyways i have a tech demo now and in theory it should show you some pictures but if it doesn't i'd like to know about it. I already had some one test this and it didn't work.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

Re: Blue Source code (1 game complete, 1 update, WIP 1)

Postby OwnerOfSuccuby » Fri Jan 25, 2013 4:46 pm

Some updates in project that we a talking about ? Or another one ?
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 9:33 pm

Re: Blue Source code (1 game complete, 1 update, WIP 1)

Postby BlueLight » Fri Jan 25, 2013 6:01 pm

Same one. Turns out you have to rememer what objects get made when.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

Re: Blue Source code (1 game complete, 1 update, WIP 1)

Postby BlueLight » Thu Feb 07, 2013 9:00 am

It seems I can not remember to upload a file to mediafire followed with copying the link here. Anyways i fixed most of the problems with the program. I am right now having trouble getting my kill command to work.
http://www.mediafire.com/download.php?z1mmwoeum3cn2n5

I'm really clueless as to what the problem. I'm going to have to fiddle with the debug tools to fix this. Anyways you should be able to move at all points on the map expect the walls; however random spots you can't move into (It really is random from what i can tell.) and you should be able to remove those red titles by walking over them but for some reason my program randomly decided not to work.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

Re: Blue Source code

Postby BlueLight » Sun Jul 14, 2013 8:18 am

Streaming me programming a game. For anyone who wants to watch go here https://join.me/925-403-650.
EDIT

Setters done. Moving on to starting a new game.
EDIT

Done streaming for now!
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

Re: Blue Source code

Postby IrrelevantComment » Sun Jul 14, 2013 3:30 pm

Watched a couple of minutes of the stream earlier before it ended, wondering what you were working on? Looked a bit like CoC

Also I started messing around with Java this morning, and your TicTacToe code was useful in understanding Java, so thanks for that.
IrrelevantComment
 
Joined: Tue Mar 15, 2011 7:46 pm

Re: Blue Source code

Postby BlueLight » Sun Jul 14, 2013 6:36 pm

Basically.

I need to look at that TicTacToe code again. From what i remember i was trying to create a game where you could change the rules however you wanted. For instants if you wanted for have a field of 4x10, then you could do that. for base game worked from what i remember and that's all that mattered.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am


Return to Creative Corner



Who is online

Users browsing this forum: No registered users