|It is currently Thu Mar 28, 2024 3:41 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka

Author
behumanizer
Offline
Newbie
Newbie
USER_AVATAR

Joined: Wed Aug 17, 2011 8:09 am
Posts: 0
Blog: View Blog (1)

Archives
- August 2011
Just need to complete my program for snake game
   Wed Aug 17, 2011 8:17 am


Search Blogs


 [ 1 blog ] 

Display posts from previous:  Sort by  
Feed  
Permanent LinkPosted: Wed Aug 17, 2011 8:17 am 
Program below is working i just don't know what to do for the algorithm on keyevents for right,left,up and down
The code like y+=10; is just my assumption for the snake movement.....
I believe below the path.reset() code has to be change since stack is being use...
Can anyone help me program to run correctly?


/***
* PROVIDE THE MISSING CODE in the keyPressed() method
* in order to move the 'snake' around the interface
* by pressing:
*
* --> cursor keys
* --> CTRL-Z to 'undo' last move
* --> CTRL-Y to 'redo' past/last move
*/

package midterms;

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import java.util.*;
import javax.swing.border.*;



public class Snakes extends JPanel implements KeyListener {
final static long serialVersionUID = 1;
final private int WIDTH = 600;
final private int HEIGHT = 400;

LinkedList<Point> snake = new LinkedList<Point>();
Stack<Point> undo = new...

[ Continued ]


 Viewed 178046 times

 [ 1 blog ] 

All times are UTC [ DST ]


cron






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com