Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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 13: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 20: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 23: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 17: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 16: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 15: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 13: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 18: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 17: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]

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (12 views)
2014-07-24 01:59:36

Riven (10 views)
2014-07-23 21:16:32

Riven (11 views)
2014-07-23 21:07:15

Riven (12 views)
2014-07-23 20:56:16

ctomni231 (42 views)
2014-07-18 06:55:21

Zero Volt (38 views)
2014-07-17 23:47:54

danieldean (32 views)
2014-07-17 23:41:23

MustardPeter (34 views)
2014-07-16 23:30:00

Cero (50 views)
2014-07-16 00:42:17

Riven (50 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22 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!