Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Game Mechanics / Snake (2nd part): Smooth-Moving on: 2011-05-16 11:00:10
Hey there! persecutioncomplex

I'm still workin' on my Snake's game (latest version)! Grin I think out that I want to jump to Slick library and, by the way, I have new game's loop as well! Pointing

My next goal is to make the snake to move in constant time from A to B (let's say that length from A to B is 20 pixels), but player needs to see the snake actually moving pixel by pixel. It's like smooth-moving! SPEED is contant of snake's speed. I need to somehow implement it all... old snake, Slick and/or new loop. Any ideas? Examples, links to tutorials, anything? I know that we can figure it out! Cool
2  Games Center / Featured Games / Re: Starfarer on: 2011-05-12 18:09:07
This looks amazing! In my opinion, there should be a little bit faster game play. It looks too slow, but the effects are awesome! Roll Eyes
3  Game Development / Newbie & Debugging Questions / Re: New Member + Snake Game on: 2011-05-08 21:03:20
Yep, that did the job! Thanks again. Cheesy

I wonder... how do you know this all? I guess it's experience and I will keep asking those silly questions at least for one year. Ha, ha. Grin Grin
4  Game Development / Newbie & Debugging Questions / Re: New Member + Snake Game on: 2011-05-08 15:14:49
Great, great, great! Roll Eyes

Last thing for today... how to fix problem #3? So that snakes and all waits until user press any arrow - then only the timer is stated. New event?
5  Game Development / Newbie & Debugging Questions / Re: New Member + Snake Game on: 2011-05-08 14:52:35
Thanks a lot, Captain Awesome! That fixed mystic "2 pixels" problem! Smiley Smiley

About kieve... Thanks, thanks, thanks! But it still acts weird. Grin You see, after making you suggestions to my code... there worked as expected only left and top walls. Right and down walls didn't worked! Undecided I find a quick solution for it...

if ( right ) {

   if ( ( x[0] + ( UNIT * 2) ) > BOARDS_WIDTH ) { // Quick fix.

      willCollide = true;



if ( down ) {

   if ( ( y[0] + ( UNIT * 2 ) ) > BOARDS_HEIGHT ) { // Quick fix.

      willCollide = true;



But why it acts like that?! So weird! Final code is here...
6  Game Development / Newbie & Debugging Questions / Re: New Member + Snake Game on: 2011-05-08 13:03:00
Okey... It's so f*ckin' weird that none can't see my mistake! I will try to explain again.

I'm creating Snake's clone. My app have too classes: and

Right now I have three problems:

1) There are two constants - BOARDS_WIDTH, BOARDS_HEIGHT. They are meant to be dimensions for playground where snake moves and collects apples. It's dynamic (thanks to kieve) and I can set them as I want. For example 640 x 480, 160 x 160 or whatever. Only thing I need to keep in my mind is that both numbers must divide with 16. Why? Because constant UNIT is set to 16 x 16 and, for example, when board's dimensions are set to 160 x 160, it means that there would be 10 x 10 units large playground (160 / 16 = 10). Problem: playground is always two pixels (not units) larger than it meant to be. Like if I have set dimensions to 160 x 160, actual dimensions will be 162 x 162! Here are screenshot...

If you measure this image... after pill (apple, if you like) there are two extra pixels.

2) Collisions. I think - it's because problem #1. You see, there are code lines...

if( x[0] < 0 || x[0] > BOARDS_WIDTH || y[0] < 0 || y[0] > BOARDS_HEIGHT ) {

   inGame = false;


They should prevent snake from going into walls. Actual result is that snake goes few units in the wall - then only the game stops... i want it to stop exactly when snake collide with the wall!

3) How to make snake start to move only when users clicks any of arrows? Right now it's like snake starts to move her body, but her head is stopped. After joints * DELAY snake's all joints are under her head! Ha, ha...

7  Game Development / Newbie & Debugging Questions / Re: New Member + Snake Game on: 2011-05-08 11:16:29
I switch to java.util.Timer... It doesn't get any better!!
8  Game Development / Newbie & Debugging Questions / Re: New Member + Snake Game on: 2011-05-07 16:48:44
Yay! Thanks for you reply. Roll Eyes

I changed those fields access to 'protected' and changed code in Snake() method as you said, but that didn't help. The problem still remains... if it's measured using old-good "Print Screen" - it's 642 x 482! Weird. This is the common problem that needs to be solved.

Second, your collision problems are being caused by the lack of a real game loop.

I could use threads there... Would it be okey?

This is your start position. for the center of the board, use:
x[0] = BOARDS_WIDTH / 2;
y[0] = BOARDS_HEIGHT /2;

This helped... a little. Right now the start position is like in middle, but there are strange bug - when initGame() is called there are drawed parts of snake in top vertically and center horizontally. They disapper after 4 * DELAY miliseconds. So... threads is the way? persecutioncomplex

You have inspired me to convert the snake game I wrote using Canvas and Graphics2D objects into a tutorial.

If I understood you correct... I can wait awesome tutorial about Snake from you? Kiss
9  Game Development / Newbie & Debugging Questions / New Member + Snake Game on: 2011-05-07 15:25:33
Hey there! I'm so happy to be here... with Java programmers. It wasn't as easy as you might think - it was hard to sign up here, because of test question. Ha, ha... Grin

So... I'm daGrevis and I would love to be active member here for the next few years. Until Scala or Clojure will replace Java! Roll Eyes

I'm not so experienced as you guys... so it would be great to get some feedback! I'm working on Snake game in 2D... it's based on this tutorial. There are still lot of things that I don't understand.

I need explanation! Huh

Here are my source files...

Here are my problems...

  • The board's width and height. It should be 640 * 480 and one unit should be 16 * 16. The board is 642 * 482,
  • Collisions. I tried it normal... I tried it insane, but all time it somehow don't work. I speak about checking for walls (left, right, up, down wall). The snake goes some units (or pixels) after the wall... then the game ends (it should end immediately after crash with wall),
  • Start position of the snake. I can't figure out how to get it in the middle (center horizontally and vertically) and it's head in left side.

These are common problems right now. I hope that you could help! Smiley
Pages: [1]
EgonOlsen (77 views)
2018-06-10 19:43:48

EgonOlsen (57 views)
2018-06-10 19:43:44

EgonOlsen (77 views)
2018-06-10 19:43:20

DesertCoockie (259 views)
2018-05-13 18:23:11

nelsongames (157 views)
2018-04-24 18:15:36

nelsongames (156 views)
2018-04-24 18:14:32

ivj94 (897 views)
2018-03-24 14:47:39

ivj94 (161 views)
2018-03-24 14:46:31

ivj94 (810 views)
2018-03-24 14:43:53

Solater (174 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!