Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 I am having trouble with this car movement and collision
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
we64




PostPosted: Sun Feb 22, 2004 12:05 pm   Post subject: I am having trouble with this car movement and collision

When I run this in Windows XP and it is kind of slow. I checked the task manager and it shows that cpu has been using 100%. I don't know why, is the code not efficient or something?

code:

var chars : array char of boolean
var x, y : int := 0
var winID : int
winID := Window.Open ("position:centre;top,graphics:600;670")

View.Set ("offscreenonly")

loop
    View.Update
    drawline (90, 0, 90, maxy, black)

    drawfillbox (100 + x, 110, 125 + x, 175, white)   %Body
    drawfillbox (95 + x, 120, 100 + x, 130, white)   %Left Rare Tire
    drawfillbox (95 + x, 155, 100 + x, 165, white)  %Left Front Tire
    drawfillbox (125 + x, 120, 130 + x, 130, white)   %Right Rare Tire
    drawfillbox (125 + x, 155, 130 + x, 165, white)   %Right Front Tire

    drawfillbox (300, 400 + y, 350, 350 + y, white) %Block
    Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) then
        y -= 1
    elsif chars (KEY_DOWN_ARROW) then
        y += 1
    elsif chars (KEY_LEFT_ARROW) then
        x -= 1
    elsif chars (KEY_RIGHT_ARROW) then
        x += 1
    end if

    if x <= -7 then
        x := 0
    end if

    drawfillbox (300, 400 + y, 350, 350 + y, blue)     %Block

    drawfillbox (100 + x, 110, 125 + x, 175, 40)  %Body
    drawfillbox (95 + x, 120, 100 + x, 130, black)   %Left Rare Tire
    drawfillbox (95 + x, 155, 100 + x, 165, black)   %Left Front Tire
    drawfillbox (125 + x, 120, 130 + x, 130, black)   %Right Rare Tire
    drawfillbox (125 + x, 155, 130 + x, 165, black)   %Right Front Tire

    if 350 + y <= 176 and 100 + x >= 300 and 100 + x <= 350 then
        exit
    end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
jonos




PostPosted: Sun Feb 22, 2004 12:15 pm   Post subject: (No subject)

on my comp its fine, maybe your ram is full (im guessing i don't know if thats possible), you might want to restart your comp, sometimes my lags up if its on for a week or so (like now). the code is fine, though i hvaen't had to good a look. anyways, it looks good, nice start to a game.
Cervantes




PostPosted: Sun Feb 22, 2004 12:40 pm   Post subject: (No subject)

works fine for me too

here's a TIP: when using Input.KeyDown combined with if statements, don't use elsif. Use separate if..end if statements. That way you can move both the car and the block at the same time.

jonos: you leave you're comp on for a week?! what's the point! Turn it off when you're not using it, it saves energy.
josh




PostPosted: Sun Feb 22, 2004 1:52 pm   Post subject: (No subject)

on my computer the CPu usage spiked to 72% for a sec and the icon that appears on the taskbar materialized really slowly.
we64




PostPosted: Sun Feb 22, 2004 8:27 pm   Post subject: (No subject)

rhysticlight wrote:
on my computer the CPu usage spiked to 72% for a sec and the icon that appears on the taskbar materialized really slowly.

yeah, this is exactly what happened to me...
jonos




PostPosted: Mon Feb 23, 2004 7:24 am   Post subject: (No subject)

how fast is your comp... cpu speed, and ram.

i leave my computer on if im buying something really big, thats all. except i have i think 4 fans in my computer so its pretty loud at night.
we64




PostPosted: Mon Feb 23, 2004 7:49 am   Post subject: (No subject)

I think my computer is fast enough: 1.3 G Duron, 512 RAM
jonos




PostPosted: Mon Feb 23, 2004 8:23 am   Post subject: (No subject)

yeah, that should be alright, maybe you are running too many programs, or have a lot of spyware/adware in the background.
josh




PostPosted: Mon Feb 23, 2004 4:15 pm   Post subject: (No subject)

512 ram, AMD Athalon 2.13GHZ. Pretty new. And I only had one other program oppened.
jonos




PostPosted: Mon Feb 23, 2004 5:20 pm   Post subject: (No subject)

well, the only other thing i could think about without making me seem too stupid, would be: what version of turing are you using (probably the new one)

anyways, maybe reload turing or something. i have no idea.
Cervantes




PostPosted: Mon Feb 23, 2004 7:15 pm   Post subject: (No subject)

I think that Turing can sometimes initiate an "owning" sequence on the computer. it seems to fill up the computer's RAM really fast, and then it multiplies the slowness of full RAM by 100 by running itself slowly.
Anyways just restart your comp it should work fine.
the_short1




PostPosted: Tue Feb 24, 2004 8:05 am   Post subject: (No subject)

here try this out:
http://jfitz.com/software/RAMpage/
double clicking this icon in the TASK BAR... will free up the amount of ramp you configured it for... (if i can be freed)

how this works:

it acually says I NEED RAM to computer... so computer steals from Programs that no longer need it... or forgot to free after closing...

then releases it properly....

you can either have a shortcut to the config or the normal of the program... i like the config versizon better..... the normal one cant change settings on the fly... you have to re open the config version then the normal... but the config version always pops up with the config window on start up... w/e you like i guess..


BOTTOM LINE: Use this b4 running a major Appp like turing and it should help... it also shows current ram that is FREE, total Page memory... and virtual...Also .... CLOSE Kazaa...<<<its a Biatch>>> unlessu acually using it
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: