Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-12-2002, 04:01 PM   PM User | #1
katja
New to the CF scene

 
Join Date: Oct 2002
Location: Gothnburg, Sweden
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
katja is an unknown quantity at this point
Unhappy Java game

Hello! I'm trying to write a game in Java. The Sea Battle game where you should hit and sink the opponents ships...
It has to be in a field 10x10 squares and i had written the code for a square. Here it is:
import java.awt.*;
import javax.swing.*;

public class Tile extends JButton{
public Tile() {
super("");
}
public void paintComponent (Graphics g) {
g.setColor (getForeground());
}
}

But i have know idea what to do next. I know I should put them in a Grid Layout, but how the hell should I programm the ships?
katja is offline   Reply With Quote
Old 10-14-2002, 04:02 PM   PM User | #2
Shawn Curry
New Coder

 
Join Date: Oct 2002
Location: middle of nowhere
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Shawn Curry is an unknown quantity at this point
Making a game is no easy task... There are utilites for rendering 3d objects and extracting all the sprites you need. As for torpedoes and blowing ships up, thats gonna take some heavy math. You need to generate an applicable physics model (Vectors for the torpedo trajectory, coordinates of all the ships, and the outline of the ships to register hits, etc). It would be cool to explain it in a couple paragraphs, but people go to college for YEARS to study programming, and study programming for YEARS after they get out to get good at game programming. I'd reccommend "Tricks of the Windows Game Programming Gurus" by Andre LaMothe(SAMS) for starters, but your gonna need some understanding of C to see whats going on.
Shawn Curry is offline   Reply With Quote
Old 10-14-2002, 06:24 PM   PM User | #3
katja
New to the CF scene

 
Join Date: Oct 2002
Location: Gothnburg, Sweden
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
katja is an unknown quantity at this point
Java Game

No,No,No... Not thst kind of game. The game like in the attached picture. THe concept is:
You have a board with squares 10x10, where you can randomly place 1 4-squared ship, 2 3-squared, 3 2-squared and 4 1-squared. Ships can only be placed vertically or horisontally (not diagonally) and the squared of two different ships can't touch each other. The play should try to hit all the ships in as little time as possible. Look at the attached picture. The red squares are the ships the player has killed and the crosses are the empty spots where there aren't any ship. It's extremely simple game which requares a little knowledge in Java (My teacher said he could write this game in an hour, I can't).
Anyway if you can't help me with this, maybe you vcan help me to write a code for the TicTacToe?
Attached Thumbnails
Click image for larger version

Name:	sankaskep.jpg
Views:	309
Size:	14.1 KB
ID:	341  
katja is offline   Reply With Quote
Old 10-16-2002, 02:33 PM   PM User | #4
tommysphone
Regular Coder

 
Join Date: Jun 2002
Posts: 262
Thanks: 0
Thanked 0 Times in 0 Posts
tommysphone is an unknown quantity at this point
Battleships

A great game. My brother and I played this for hours when we were kids. Great for rainy days.

html page and images attached. Save in the same folder and play on
__________________
Therapy is expensive, popping bubble wrap is cheap, you choose.
tommysphone is offline   Reply With Quote
Old 10-16-2002, 02:36 PM   PM User | #5
tommysphone
Regular Coder

 
Join Date: Jun 2002
Posts: 262
Thanks: 0
Thanked 0 Times in 0 Posts
tommysphone is an unknown quantity at this point
tic tac toe

Here is the script (attached) Njoy.
Attached Files
File Type: zip tictactoe.zip (1.9 KB, 365 views)
__________________
Therapy is expensive, popping bubble wrap is cheap, you choose.
tommysphone is offline   Reply With Quote
Old 10-16-2002, 02:37 PM   PM User | #6
tommysphone
Regular Coder

 
Join Date: Jun 2002
Posts: 262
Thanks: 0
Thanked 0 Times in 0 Posts
tommysphone is an unknown quantity at this point
The battleships stuff would help

Sorry, here it is. Save it all in the same folder etc etc.

On another note, I know you where supposed to write this yourself but a teacher should not boast about how quikc or how good they are but encourage a pupil. So we are getting our own back.
Attached Files
File Type: zip thegame.zip (6.9 KB, 413 views)
__________________
Therapy is expensive, popping bubble wrap is cheap, you choose.

Last edited by tommysphone; 10-16-2002 at 02:45 PM..
tommysphone is offline   Reply With Quote
Old 10-16-2002, 05:07 PM   PM User | #7
katja
New to the CF scene

 
Join Date: Oct 2002
Location: Gothnburg, Sweden
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
katja is an unknown quantity at this point
Smile

Thank you all very much, but I don't need an applet. I need the program which extends from JFrame and has a main method:
public static void main (string[] agrs){...}
katja is offline   Reply With Quote
Old 10-16-2002, 06:09 PM   PM User | #8
katja
New to the CF scene

 
Join Date: Oct 2002
Location: Gothnburg, Sweden
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
katja is an unknown quantity at this point
Java Game

Another tricky question.
A have another game, consept is that a player pushes the "Start" button an dbackground should change color, as soon as that happened tha player should press the "stop" button, and tha message dialog should come out telling the player how much time did it take for him to push the "stop" button. Any ideas how to do that?
katja is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:28 AM.


Advertisement
Log in to turn off these ads.