Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hello every one I wrote a game in C# form that I have 2 (picture box) that their shape is car and I can control their by keyboard and mouse.after a time my game over (such as 60 second )I want reply of my game this means that such as need for speed games that have reply for games I want reply of that thank yoooooooooooooooooooooou
Posted
Comments
Kim Togo 30-Jul-11 11:07am    
Please use "Add Comment" and not "Add a Solution" when replying to a solution.

1 solution

In order to do an "action replay" - which is what I think you are asking for - you would have to record every action taken by the "cars" - if the user starts them moving left, you have to record when, and how far. If he starts them moving slightly less left, again, you need to know when and how much.
Or, you need to record the exact path taken by each car. I.e. if you are drawing/moving them in a timer, then every tick, you must record where you are drawing or moving them to.
You then need to feed this info back into your game to show the replay - exactly how is difficult to say without knowing a lot more about your game.



"very sorry Mr or miss OriginalGriff I can record my cars location in a notepad file but I cannot read from them tomorrow I must deliver this project to my master please help me"


Okay, a notepad file is a bad idea!
Looking at yiu deleted question (I have a problem in reading information from text[^]) it is difficult to work out how you are doing this: "434 234 567 764 238" looks as if it should be coordinates of some kind, but they do not look complete so it is difficult to tell.

I don't know how you are implementing your game, but the way I would do it (at least to start with) would be to have two "velocities" per car: Left and forward, where zero was "no left", positive was "some left" and negative was "some right", and so forth.
I would then set up a timer of (say) 40 milliseconds interval. Each time the timer ticked, I would add the velocity for each car to the appropriate vehicle, and update the picture box X and Y positions.
Each time the user moved the mouse / keyboard, it would affect the value in the appropriate velocity only.

To do an action replay with this, I would set up a List<Point> per car, and each time I executed the timer Tick event, I would add the current position to the appropriate list. Then, to run the replay, set the initial positions again, and each Tick, just use the next value from each list as the direct position for each car rather than using the velocities to calculate a new position.

Again, I don't know how you are doing it, but you scheme is likely to be similar in some respects - you should be able to modify this to fit how you code works. :)
 
Share this answer
 
v2
Comments
Kim Togo 30-Jul-11 11:06am    
From OP

Thank you very very much if I send you my game can you create reply for that?
OriginalGriff 30-Jul-11 11:17am    
No, sorry - I don't have time to work out how you are doing things - and if I did, how would you learn to do it next time? :laugh:

It's not difficult - take it in easy stages:
1) Set up a List to hold your data.
2) Add your car locations to the list while you move them
3) Set up a timer to replay it.
4) Each tick, move the car.
_Starbug_ 30-Jul-11 12:39pm    
very sorry Mr or miss OriginalGriff I can record my cars location in a notepad file but I cannot read from them tomorrow I must deliver this project to my master please help me
OriginalGriff 31-Jul-11 4:09am    
Answer updated.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900