laptimes/splitimes, moving cars in racing management game

Non-platform specific questions.

laptimes/splitimes, moving cars in racing management game

Postby extremalyfresh » Tue Jan 17, 2012 12:34 pm

Hi guys. It is my first post here so let me please say hello and explain what I am doing here. I try to work on kind of racing team management game. I found a lot of useful topics on this forum in last weeks but almost all of them are focused on platform, rpg or arcade games. Maybe it is my lack of imagination only :-) but I can't get exactly what I want from the examples.

That is why I decided to write a post with hope that you guys can help me understand some things or to give me some ideas maybe.

I have 2 difficult points in my work for now. First is how to make a sort of code which gives me splittimes and laptimes of cars. Probably I can make some unefficient code by myself :-) but I need a code which handles about 20-30 cars and that can be complicated (or not?). I know basically how to display results (again probably not so efficient but still :-)) but I need the counting and storing engine idea, which GE functions would be the best or how should I write my own function of this type.

The second one is about moving cars around the track and controlling his speed depends on variables like speed, acceleration, braking. These valiues should change during race (depends on car/driver attributes) so I can't use paths for instance.

Any ideas will be helpful, even links to other topics because I'm not 100% sure I haven't miss any :-).

If you have any questions, please ask.

Thanks in advance.
Do you speak Polish? If yes here is a useful Game Editor website for you:
http://www.sgames.pl/
You can find some useful articles and examples there.
You can try and test a Quiz Game as well.
It has been made with use of Game Editor.
extremalyfresh
 
Posts: 13
Joined: Thu Dec 22, 2011 3:36 pm
Location: Poland
Score: 0 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby SuperSonic » Tue Jan 17, 2012 5:33 pm

Hi extremalyfresh and welcome to the forums :D

I myself am not a coding expert but I can help you with your acceleration problem. To make a car accelerate, first you must make an actor integer in global code called acceleration. Then you should make a draw actor event for your car and choose script editor for the action. Then you can input this:
Code: Select all
directional_velocity += acceleration;

Then all you have to do is change the acceleration variable at different points in your game. For example:
Code: Select all
acceleration = .5;//The car will start to speed up

Code: Select all
acceleration = -.5;//The car will start to slow down and reverse

Code: Select all
acceleration = 0;//The car will keep a steady speed

I hope that was helpful :P
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby extremalyfresh » Tue Jan 17, 2012 7:50 pm

Actually I already know that :-). But thanks anyway. You at least try :-). I need something like how to make cars following a race track surface, quite curvy sometimes. I have some idea already but I'm not sure if it's a good one for my needs and how to get it work properly.

The idea is to make clones of specific actor which are kind of targets for cars on their road. All clones are spread through the track length. The car should direct to the actor.1 first. When the car is closing to the actor.1 it switches to the next one (actor.2) and so on. It is not a bad idea but I thought maybe someone has better or at least different to think about and can show me some example maybe :-).

Any idea how to manage laptimes/splittimes? I know that probably getTime function can be useful. I can probably compare getTime function results from checkpoints placed on race track and this way get proper laptimes. But how to code it properly to make it work during the whole race and then keep results for statistics purposes?
Do you speak Polish? If yes here is a useful Game Editor website for you:
http://www.sgames.pl/
You can find some useful articles and examples there.
You can try and test a Quiz Game as well.
It has been made with use of Game Editor.
extremalyfresh
 
Posts: 13
Joined: Thu Dec 22, 2011 3:36 pm
Location: Poland
Score: 0 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby SuperSonic » Tue Jan 17, 2012 9:43 pm

extremalyfresh wrote:The idea is to make clones of specific actor which are kind of targets for cars on their road. All clones are spread through the track length. The car should direct to the actor.1 first. When the car is closing to the actor.1 it switches to the next one (actor.2) and so on.

Your idea of pathfinding is actually a good one :wink:

As for laptimes, I made a tutorial on creating timers that you can find in the online tutorials. The only problem is that the tutorial was made for count down timers. Not the type that record time. However, you could easily change bits of the code to make it work for what you are wanting. If you need help changing it, I'd be glad to assist you :D

Here's the link to it:
viewtopic.php?f=1&t=11455#p80602
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby extremalyfresh » Wed Jan 18, 2012 10:08 am

I've seen it already but your advices are still helpful because I wasn't sure If I should use that kind of code for my laptimes before :-). I'll try to work it out and post results here so you can take a look.

By the way, here is a + for your help :-).
Do you speak Polish? If yes here is a useful Game Editor website for you:
http://www.sgames.pl/
You can find some useful articles and examples there.
You can try and test a Quiz Game as well.
It has been made with use of Game Editor.
extremalyfresh
 
Posts: 13
Joined: Thu Dec 22, 2011 3:36 pm
Location: Poland
Score: 0 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby SuperSonic » Wed Jan 18, 2012 4:00 pm

extremalyfresh wrote:I've seen it already but your advices are still helpful because I wasn't sure If I should use that kind of code for my laptimes before :-). I'll try to work it out and post results here so you can take a look.

By the way, here is a + for your help :-).

Thanks :D
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby extremalyfresh » Fri Jan 20, 2012 11:47 am

Ok, after some silly trouble with collision event I managed to make my car mvoe around the track. There is an actor showing live race time and finished laps. Now I'm a bit jammed because I'm not sure which function should I use to store laptimes and what is the right order of the code. I know that probably I should use sprintf function and maybe something more but I don't know how to use it for my game. I need your help guys :-).

In my words that should be something like this:

1.The timer starts counting when the car starts (that is already done)
2. After the car is crossing a finish line - lap_counter++ (already done) and Lap Time actor (maybe the same as timer one) remebers the timer variables state to get actual race time and substracting previous lap race time from it (on first lap that would be 0). In result we should get proper lap time I think.
3. After that the new lap time should be comapred to best one of the car and the best one should be exchanged with the new one if the new one is worse :-). Then displayed.
4. All lap times should be stored in array and displayed as well.

Is this possible to make something like that using a loop (loops) to wrap the whole race and save some space in the script?

Here is my ged file:
Attachments
lap_timer.zip
(444.64 KiB) Downloaded 182 times
Do you speak Polish? If yes here is a useful Game Editor website for you:
http://www.sgames.pl/
You can find some useful articles and examples there.
You can try and test a Quiz Game as well.
It has been made with use of Game Editor.
extremalyfresh
 
Posts: 13
Joined: Thu Dec 22, 2011 3:36 pm
Location: Poland
Score: 0 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby extremalyfresh » Mon Jan 23, 2012 9:45 am

Nobody even wants to criticize my project? Come on people :-).
Do you speak Polish? If yes here is a useful Game Editor website for you:
http://www.sgames.pl/
You can find some useful articles and examples there.
You can try and test a Quiz Game as well.
It has been made with use of Game Editor.
extremalyfresh
 
Posts: 13
Joined: Thu Dec 22, 2011 3:36 pm
Location: Poland
Score: 0 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby SuperSonic » Mon Jan 23, 2012 6:19 pm

Hey there :D

I took a looksee at your project and I really like it. The color scheme and everything seems to match very well :wink:

As for your problem, I'm working on a way to fix it and I'll try to upload it today :P
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby extremalyfresh » Tue Jan 24, 2012 5:33 pm

I appreciate that :-). I am trying to overpass all difficulties somehow but for now I get strange results. I can't even upload any example because it's a mess :-).

Instead here is what I'm trying to do:

car collision event (with finish_line):
//temporary variables storing global LapTimer variables state (hours, minutes, seconds, milliseconds) at the moment of collision
l0=LapTimer[0];
l1=LapTimer[1];
l2=LapTimer[2];
l3=LapTimer[3];

//writing those variables into one string
sprintf(Laps[0], "%i:%i;%i;%i", l0, l1, l2, l3);

in lap_timer draw event (actor which draws all my data for now):

sprintf(text, "Time: %i:%02i:%02i:%03i\nLap: %i\nLapTime: %i", LapTimer[0], LapTimer[1], LapTimer[2], LapTimer[3], lap_counter, Laps[0]);

All staff is displayed properly except the Laps[0] variable (it is a global variable). It shows long number (something like that 100200605834) instead of time form and digits are the same when I open the ged file once but for example next day they are different but not changing during the race.
I am not sure if I use properly the first argument of the sprintf function to be honest.
Do you speak Polish? If yes here is a useful Game Editor website for you:
http://www.sgames.pl/
You can find some useful articles and examples there.
You can try and test a Quiz Game as well.
It has been made with use of Game Editor.
extremalyfresh
 
Posts: 13
Joined: Thu Dec 22, 2011 3:36 pm
Location: Poland
Score: 0 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby SuperSonic » Wed Jan 25, 2012 12:00 am

I think the problem with your code at the bottom is that Laps is a character. So change that last %i to %s for string. I dunno if that will fix it or not though :)

And, I've been working on implementing the functions you wanted. I have almost gotten it to work. Ther's just one weird bug. But I'll finish it and upload it soon :wink:
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby extremalyfresh » Wed Jan 25, 2012 9:52 am

Thanks mate :-). It is almost always so simple mistake which stops me. Now it works perfect. I will work more on that later and waiting for your example.
Do you speak Polish? If yes here is a useful Game Editor website for you:
http://www.sgames.pl/
You can find some useful articles and examples there.
You can try and test a Quiz Game as well.
It has been made with use of Game Editor.
extremalyfresh
 
Posts: 13
Joined: Thu Dec 22, 2011 3:36 pm
Location: Poland
Score: 0 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby SuperSonic » Wed Jan 25, 2012 4:41 pm

The problem with my example right now is that I'm not sure if the laptimes are getting stored correctly. I need to do a few tests to make sure. Once that's done, I'll work on making them get displayed :D
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby extremalyfresh » Wed Jan 25, 2012 8:43 pm

Sounds great for me :-). I'm trying to get some results on my own too but now I have some strange problems with GE itself. It's crashing every second time when I hit game mode button or when I want to save game and sometimes I'm loosing my work because of that. It is not the case if I use save as. What can be the reason of such behavior?
Do you speak Polish? If yes here is a useful Game Editor website for you:
http://www.sgames.pl/
You can find some useful articles and examples there.
You can try and test a Quiz Game as well.
It has been made with use of Game Editor.
extremalyfresh
 
Posts: 13
Joined: Thu Dec 22, 2011 3:36 pm
Location: Poland
Score: 0 Give a positive score

Re: laptimes/splitimes, moving cars in racing management gam

Postby SuperSonic » Wed Jan 25, 2012 9:59 pm

extremalyfresh wrote:What can be the reason of such behavior?

I'm not really sure but saving and loading files could have something to do with it :P

And I have run into another weird bug with my example. I'm still trying to figure it out. I may have to restart if I can't find the problem :(
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest