Game speed

You must understand the Game Editor concepts, before post here.

Game speed

Postby DilloDude » Wed Jun 07, 2006 12:46 am

This may not sound too advanced, but it may be a new idea to some. I have not tried doing this exactly, but I have done similar things. In some games there are settings to change the speed, to make it harder or easier. THere may also be bonuses to go slow motion. Well, it can be done. It is probably best if you start a new game, because of the editing you need to do. Create a global variable, 'gameSpeed', and set it to 1 on view's create actor. Make sure it is a real number. On all actors that are affected by speed, use draw actor to assign increases and velocity etc. So you might need a couple of actor variables, like extra velocity. A couple of examples
Code: Select all
if (circumstance)
{
    xvelocity = xvel * gameSpeed;
}//where xvel is a variable that represents xvelocity

Code: Select all
//for movement
if (moving)
{
    switch (direction)
    {
        case RIGHT:
        x += 5 * gameSpeed;
        break;

        case LEFT:
        x -= 5 * gameSpeed;
        break;
    }
}

//for gravity
if (yvel < maxgrav)//maxgrav is the maximum gravity multiplier - if you make a variable you can adjust it when you are in water etc.
{
    yvel += gravstr;
}//gravstr is the increase in gravity, you can adjust it when you want to fall at different rates, like maxgrav
yvelocity = yvel * gameSpeed;

When you have this set up, you can adjust the speed. If you want to go at half the speed, set gameSpeed to .5, or to go at double speed, set it to 2.
You can try other values, like .25, .75, 1.5, etc. You could even make it go backwards (confusing).
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DilloDude » Wed Jun 07, 2006 12:51 am

You could make gameSpeed an actor variable if you want to have things such as slowing everything but you down, or have the global set slow, and have you affected by a different one, or various things. Do it however you want, and try experimenting to get the desired result.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DilloDude » Wed Jun 07, 2006 1:03 am

Another thing I forgot to mention, is changing the speed of timers. In this case you will want time rate to change, so use an actor real variable called 'time'. On draw actor
Code: Select all
time += gameSpeed;
if (time >= MAXTIME)//MAXTIME is the variable to count to
{
    //script to activate on timer
    //reset timer or disable it
}
to change speed of animations, use a time in this way for a defult (at normal speed of 1) time of 1 frame.
Code: Select all
time += gameSpeed;
int anim = animpos;
int stop = 0;
while (time >= 1)// use a while rather than an if, adjust for slower anim speeds
{
    anim += 1;
    if (anim >= nframes)
    anim = 0;
    time -= 1;
    stop = 1;
}
if (stop)//reset time if time exceeded limit
{
    time = 0;
}
animpos = anim;
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest