473,395 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Timer

mishela
11
Hello,
I have a program - it is accually a game, BoulderDash. A man runs an collets some crystals and when he has already collected the needed amount of crystals, he goes to the given destination and goes to another level. In the game besides the crystals there are also stones. When a stone or a crystal falls on the man's head, the game is over. The stone or crystal cannot fall from the grass or wall, but from another stone or crystal it can fall to the right or to the left.

Now I have made the program, I have the man moving across the game field, he collets the crystals, the stones are falling too. But there is a problem, when the man goes under the stone, this stone moves only when the man is moving, to steps with the man (I don't know if this is correct english, I hope you'll understand). So it is impossible to kill the man, because the man MUST go a step somewhere else, so that the stone can move a tile further.

I would like to make such thing, when the man goes under the stone, the stone falls abstractedly from the man. I want to use Timer, but I think, there's a little more needed, because the current operation, which is actually executing, must be suspended in a moment, when the player pushes some arrow. And I think, that javax.swing.Timer takes all the events and enqueques them into the queue of events, so they all will be accomplished. I need only the current event to be accomplished, and if there is some executing, it must be suspended.
I don't know how to do it, can somebody help me? Please..
Jun 28 '07 #1
6 1350
r035198x
13,262 8TB
Hello,
I have a program - it is accually a game, BoulderDash. A man runs an collets some crystals and when he has already collected the needed amount of crystals, he goes to the given destination and goes to another level. In the game besides the crystals there are also stones. When a stone or a crystal falls on the man's head, the game is over. The stone or crystal cannot fall from the grass or wall, but from another stone or crystal it can fall to the right or to the left.

Now I have made the program, I have the man moving across the game field, he collets the crystals, the stones are falling too. But there is a problem, when the man goes under the stone, this stone moves only when the man is moving, to steps with the man (I don't know if this is correct english, I hope you'll understand). So it is impossible to kill the man, because the man MUST go a step somewhere else, so that the stone can move a tile further.

I would like to make such thing, when the man goes under the stone, the stone falls abstractedly from the man. I want to use Timer, but I think, there's a little more needed, because the current operation, which is actually executing, must be suspended in a moment, when the player pushes some arrow. And I think, that javax.swing.Timer takes all the events and enqueques them into the queue of events, so they all will be accomplished. I need only the current event to be accomplished, and if there is some executing, it must be suspended.
I don't know how to do it, can somebody help me? Please..
I'm sorry I didn't fully get your explanation. I don't want you to have to post all your code (I don't think it's necessary a.t.m) but why not freeze everything when you want to drop the stone on the man's head (everything except the stone of course).
Jun 28 '07 #2
mishela
11
because the man must have an opportunity to run away from that stone, but if he doesn't make it until the stone falls, he is killed by it..
The original game can be downloaded here:
http://www.zxgames.com/en/boulderdash.shtml
and here:
http://boulder-dash.en.softonic.com/
Jun 28 '07 #3
r035198x
13,262 8TB
because the man must have an opportunity to run away from that stone, but if he doesn't make it until the stone falls, he is killed by it..
The original game can be downloaded here:
http://www.zxgames.com/en/boulderdash.shtml
and here:
http://boulder-dash.en.softonic.com/
Correct me if I'm wrong.

Assumption 1.) The stone moves independantly of the man.
Assumption 2.) The man is considered hit if the stone comes into contact with any part of him.

Now according to your ealier description, it seems that assumption 1 is not being satisfied.
Jun 28 '07 #4
mishela
11
Correct me if I'm wrong.

Assumption 1.) The stone moves independantly of the man.
Assumption 2.) The man is considered hit if the stone comes into contact with any part of him.

Now according to your ealier description, it seems that assumption 1 is not being satisfied.
1.)correct
2.)The stone falls from up to down, so if it falls to the head of the man it will kill him. Exactly like in that original game.
Yes, the assumption 1 is not being satisfied.
Jun 28 '07 #5
r035198x
13,262 8TB
1.)correct
2.)The stone falls from up to down, so if it falls to the head of the man it will kill him. Exactly like in that original game.
Yes, the assumption 1 is not being satisfied.
Well I'm not a fan of having large amounts of code posted. So could you explain how you are moving the stone and how you are moving the man so that we can see why these two movements are not happening independant of each other.
Jun 28 '07 #6
mishela
11
the whole code is based on this logic:

while(some stone is falling in the field) {
for(every row in the field) {
for(every column in the field) {

if(tile[row][column] is not a stone or crystal - something that cannot fall) {
//do nothing
}

else if(tile[row][column] is a stone or crystal - something that can fall) {

if(the tile under the tile[row][column], that means tile[row-1][column] is a blank tile) {
//the stone falls one tile down and if there is a man two tiles down, the stone will then kill him
}

else if(the tile under the tile[row][column], that means tile[row-1][column] is something from the stone or crystal can fall, that means, it is a stone, a crystal, a man, or a wall) {
//the stone falls only if there is a blank area left or right
}

}

}
}
printField();
}


in a simple version..


And a move is simple: if the man has where to move - that means, if in the direction is a tile that is blank, or there is a grass, he is moving one tile in that direction, and the field is tested for falling stones (that algorithm up).
If the man goes left or right, and in the direction there is a stone and a blank tile after, the man pushes the stone to that blank tile, and again the field is tested for falling stones.
If there is something else in the direction, do nothing.
Jun 28 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null;...
2
by: John David Thornton | last post by:
I've got a Windows Service class, and I put a System.Threading.Timer, and I've coded it as shown below. However, when I install the service and then start it in MMC, I get a peculiar message: ...
12
by: Gina_Marano | last post by:
I have created an array of timers (1-n). At first I just created windows form timers but I read that system timers are better for background work. The timers will just be monitoring different...
8
by: KnighT | last post by:
I have a .net service that runs a System.Threading.Timer. The delegate points to the function that the service should execute when the timer elapses. Problem: The timer is not ticking. I have...
8
by: =?Utf-8?B?RGF2ZSBCb29rZXI=?= | last post by:
I have a Timer that I set to go off once a day, but it frequently fails! In order to debug I would like to be able to check, at any moment, whether the Timer is enabled and when it will next...
11
by: Hotrod2000 | last post by:
I'm quite new to programming but I'm having problems getting a timer to work in visual studio.net I've created a timer on a form, enabled it and then typed the following code (from the mdsn...
16
by: Peter Oliphant | last post by:
Note that although this involves SAPI, it is more a question about Timers and event handlers. I wrote a Speech Recognize handler (SAPI), and put some code in it to enable a Timer. It would not...
11
by: Anil Gupte/iCinema.com | last post by:
When I use this Dim instance As New Timer I get the error: Error 1 Overload resolution failed because no accessible 'New' accepts this number of arguments. Yet, in the help section for...
3
by: Steve | last post by:
Hi All I am using VB.net 2008 and use timer controls within my applications Question Does the code in a Timer control.tick event run on a different thread to the main Application thread (UI...
1
by: Eran Hefer | last post by:
With SharePoint timer jobs you can create & execute processes on a daily / hourly / minutely basis. After deployment, the timer job definition executes your custom code. The easiest (and more...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.