
-----------------------------------
Aange10
Sun Sep 04, 2011 12:52 pm

Changing object's movement speed
-----------------------------------
What is it you are trying to achieve?
 I'm trying to set a speed for my oval. (I'm making frogger!:D) And I'm wondering if there is some way to use a decimal in the equation... I've been reading up and I can't seem to find out how to use a decimal for the speed at which my object will travel. Right now i'm just increasing the delay after the key is pressed What is the problem you are having?
I can't put a real number in the integer syntax (?)


Describe what you have tried to solve this problem
I've gone around and tried to read about movement, and I've tried altering my coding.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)



%Frogger!
View.Set("Offscreenonly, graphics:maxx;maxxy, position:center;center, title: Frogger")
var frog1_x, frog1_y, frog1_xr, frog1_yr : int %My frog's cordinates
var chars : array char of boolean % Has to be here...
var level : int % Defines what level we are on
var continue : string  %Allows the user to continue
var mainmenu : boolean % Variable to help me tell wether or not to bring up a mian menu
var mainmenu_continue : string % Varriable to toggle main menu
var fontTNR : int % My font Times New Roman
frog1_x := 25  %Frog X
frog1_y := 25  % Frog Y
frog1_xr := 20 % Frog X radius
frog1_yr := 10 % Frog y radius
level := 1  % level
mainmenu := true
continue := "a"  %Var to continue or not
loop % Main Loop
    loop % Main menu bug proof loop
        if mainmenu = true then % Toggles main menu
            fontTNR := Font.New ("TimeNewRoman:18")
            Font.Draw ("Welcome to Frogger!", maxx div 2, maxy div 2 + 35, fontTNR, green)
            fontTNR := Font.New ("TimeNewRoman:12")
            delay (1000)
            Font.Draw ("To continue, type 'r' !", maxx div 2 + 15, maxy div 2, fontTNR, red)
            locatexy (maxx div 2 + 20, maxy div 2 - 15)
            get mainmenu_continue  %Asks if they'd like to continue (types r)
        else %If main menu is false it exits the mainmenu loop
        exit
        end if
        if mainmenu_continue = "r" then
            mainmenu := false  %If you typed 'r' it changes mainmenu to false
            cls
            exit %exits the loop
        else %If you typed anything else...
            cls
            put "That is an invalid answer!"
            delay (2000)
            cls
        end if  %Repeats loop after telling you that that is an invalid answer.
    end loop
    Input.KeyDown (chars)
        if chars ('d') then  %Frog moving to the right
            frog1_x += + 1
            delay(2)
        end if
        if chars (KEY_RIGHT_ARROW) then %^
            frog1_x += + 1
            delay (2)
        end if
        if chars (KEY_LEFT_ARROW) then % Frog moving to the left
            frog1_x += - 1
            delay (2)
        end if
        if chars ('a') then % ^
            frog1_x += -1
            delay (2)
        end if
        if chars (KEY_ENTER) then % Resets the frogs position to the starting  position
            frog1_x := 25
            frog1_y := 25
        end if
        if chars (KEY_UP_ARROW) then % Moves the frog up
            frog1_y += +1
            delay (2)
        end if
        if chars ('w') then % ^
            frog1_y += +1
            delay (2)
        end if
        if chars ('s') then % Moves the frog down
            frog1_y += -1
            delay (2)
        end if
        if chars (KEY_DOWN_ARROW) then % ^
            frog1_y += -1
            delay (2)
        end if
    loop
        if frog1_y >= 390 then  %If you get to the top it tells you that you win
        cls
            put "You win! Type 'c' to conintue!"
            get continue
    View.Update
        else
        exit
        end if
        if continue = "c" then
            cls
            level += + 1 %if you won and typed c it changes your level
            exit
        else   
        end if
    end loop
    if frog1_x 