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

Username:   Password: 
 RegisterRegister   
 Problem with graphics movement...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
BladeOfDeath




PostPosted: Sun Dec 07, 2003 1:09 am   Post subject: Problem with graphics movement...

I am currently using an if statement for my pacman's mouth. The variable is mthCls. mthCls increases by 10 each time through the loop, I need it so that once mthCls equals 30 that it will go down to 0 and when it reaches 0 it will go back up again. Could you please help, my assignment is due soon...
Sponsor
Sponsor
Sponsor
sponsor
Homer_simpson




PostPosted: Sun Dec 07, 2003 1:23 am   Post subject: (No subject)

u mean something like this:
code:

loop
    for i : 1 .. 10
        drawfilloval (320, 200, 100, i * 10, 12)
        delay (50)
        cls
    end for
    for decreasing i : 10 .. 1
        drawfilloval (320, 200, 100, i * 10, 12)
        delay (50)
        cls
    end for

end loop
BladeOfDeath




PostPosted: Sun Dec 07, 2003 2:16 am   Post subject: (No subject)

no i mean something like:

mthCls:=0 --> mthCls:= 10 --> mthCls:=20 --> mthCls:=30 --> mthCls:=20 --> mthCls:=10 --> mthCls:=0 --> mthCls:=10 --> and repeats basically...

if you can put that into an if statement i would really appreciate it...
Tony




PostPosted: Sun Dec 07, 2003 3:16 am   Post subject: (No subject)

well do what homer did with for loops. If you want it to look old-school like it used to be, you can add by 10, so that your forloops would increase/decrease by 10 instead.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
McKenzie




PostPosted: Sun Dec 07, 2003 12:54 pm   Post subject: (No subject)

The only problem with the For loop is that if you want to move Pacman around you're out of luck (doesn't sound like he needs to.) I keeping with your original idea, I would use a second variable that will keep track of how much to add on to your mthCls variable each time around the loop.
Kinda like:
code:

var mthChange:=10
loop
     mthCls += mthChange      %mthCls := mthCls + mthChange
     if mthCls = 30 or mthCls = 0 then
          mthChange *= -1
     end if
end loop
BladeOfDeath




PostPosted: Sun Dec 07, 2003 4:14 pm   Post subject: (No subject)

Ill try that, I also have a problem with it being flashy...
Tony




PostPosted: Sun Dec 07, 2003 5:15 pm   Post subject: (No subject)

you have to use View.Update for animation not to flash. There's a tutorial on use of it available.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
BladeOfDeath




PostPosted: Sun Dec 07, 2003 5:47 pm   Post subject: (No subject)

ok thanks for all your help everybody, I greatly appreciate it...
Sponsor
Sponsor
Sponsor
sponsor
BladeOfDeath




PostPosted: Sun Dec 07, 2003 6:15 pm   Post subject: (No subject)

I tried the View.Update but it isnt working, ill upload the file... Oh by the way, I just started on it there are no levels. This is just the animations and dont change the random movements of the ghosts please...


pacman.t
 Description:
here it is...

Download
 Filename:  pacman.t
 Filesize:  7.55 KB
 Downloaded:  224 Time(s)

AsianSensation




PostPosted: Sun Dec 07, 2003 6:52 pm   Post subject: (No subject)

are you using 4.0.x? you need the newest version of turing all patched to be able to use View.Update.

another thing, try not to use process and fork, they are really really bad, almost as bad as whatdotcolor.
BladeOfDeath




PostPosted: Sun Dec 07, 2003 7:04 pm   Post subject: (No subject)

What else am i supposed to use? And i have 4.0.1p
DanShadow




PostPosted: Sun Dec 07, 2003 7:13 pm   Post subject: ..

Or of course, you could do it 8th grader style!
[This DOES NOT in any way reflect my intelligence....seriously]

code:

var pacman_x, pacman_y : int := 200
var mouth_draw_stage : int := 0
var mouth_move : string := "open"
loop
    if mouth_draw_stage < 3 and mouth_move = "open" then
        Draw.FillBox (0, 0, maxx, maxy, 255)
        Draw.FillOval (pacman_x, pacman_y, 8, 8, 14)
        delay (300)
        Draw.Line (pacman_x, pacman_y, pacman_x - 2, pacman_y + 8, 255)
        Draw.Line (pacman_x, pacman_y, pacman_x + 2, pacman_y + 8, 255)
        Draw.Fill (pacman_x, pacman_y + 7, 255, 255)
        delay (300)
        Draw.Line (pacman_x, pacman_y, pacman_x - 6, pacman_y + 8, 255)
        Draw.Line (pacman_x, pacman_y, pacman_x + 6, pacman_y + 8, 255)
        Draw.Fill (pacman_x - 3, pacman_y + 6, 255, 255)
        Draw.Fill (pacman_x + 3, pacman_y + 7, 255, 255)
        delay (300)
    elsif mouth_draw_stage = 3 then
        Draw.FillBox (0, 0, maxx, maxy, 255)
        Draw.FillOval (pacman_x, pacman_y, 8, 8, 14)
        delay (300)
        Draw.Line (pacman_x, pacman_y, pacman_x + 2, pacman_y - 8, 255)
        Draw.Line (pacman_x, pacman_y, pacman_x - 2, pacman_y - 8, 255)
        Draw.Fill (pacman_x, pacman_y - 7, 255, 255)
        delay (300)
        Draw.Line (pacman_x, pacman_y, pacman_x + 6, pacman_y - 8, 255)
        Draw.Line (pacman_x, pacman_y, pacman_x - 6, pacman_y - 8, 255)
        Draw.Fill (pacman_x + 3, pacman_y - 6, 255, 255)
        Draw.Fill (pacman_x - 3, pacman_y - 7, 255, 255)
        delay (300)
        mouth_move := "close"
    end if
    if mouth_move = "close" then
        Draw.FillBox (0, 0, maxx, maxy, 255)
        Draw.FillOval (pacman_x, pacman_y, 8, 8, 14)
        delay (300)
        Draw.Line (pacman_x, pacman_y, pacman_x + 2, pacman_y - 8, 255)
        Draw.Line (pacman_x, pacman_y, pacman_x - 2, pacman_y - 8, 255)
        Draw.Fill (pacman_x, pacman_y - 7, 255, 255)
        delay (300)
        Draw.Line (pacman_x, pacman_y, pacman_x + 6, pacman_y - 8, 255)
        Draw.Line (pacman_x, pacman_y, pacman_x - 6, pacman_y - 8, 255)
        Draw.Fill (pacman_x + 3, pacman_y - 6, 255, 255)
        Draw.Fill (pacman_x - 3, pacman_y - 7, 255, 255)
        delay (300)
    end if
    if mouth_draw_stage = 1 then
        mouth_move := "open"
    end if

%Main Program Under Here


end loop
BladeOfDeath




PostPosted: Sun Dec 07, 2003 7:15 pm   Post subject: (No subject)

this is my ISU for comp sci, I take it very seriously...
McKenzie




PostPosted: Mon Dec 08, 2003 12:38 am   Post subject: (No subject)

AZN is right. Too much forkn' around is going to be the source of endless headaches. The biggest problem is that the movement between Pac and the ghosts is not synchronized. What you need to do is simulate the simultanious movement yourself. Your mainline should look something like:
code:
%pseudo code
loop
     movePacMan                % one increment
     moveAllGhosts              % each ghost moves one increment
     checkInteractions          % someone gets eaten?
     View.Update
     exit when allDone
end loop

Because you move each character a small increment before you update the scene, they are, in effect, moving simultaneously
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  [ 14 Posts ]
Jump to:   


Style:  
Search: