Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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...

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
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: Snake.java and Board.java.

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...

1  
2  
3  
4  
5  
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! Board.java!
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.

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

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

Quote
This is your start position. for the center of the board, use:
1  
2  
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

Quote
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.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (27 views)
2014-07-29 18:09:19

Riven (16 views)
2014-07-29 18:08:52

Dwinin (14 views)
2014-07-29 10:59:34

E.R. Fleming (35 views)
2014-07-29 03:07:13

E.R. Fleming (13 views)
2014-07-29 03:06:25

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

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

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

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

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
java-gaming.org 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‑gaming.org
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!