Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Problem with graphics movement...
Author Message

Posted: 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...

Homer_simpson

Posted: 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

Posted: 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

Posted: 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.
Tony's programming blog. DWITE - a programming contest.
McKenzie

Posted: 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

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

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

Posted: 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.
Tony's programming blog. DWITE - a programming contest.

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

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

Posted: 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...

Filename:  pacman.t
Filesize:  7.55 KB

AsianSensation

Posted: 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.

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

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

Posted: 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

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

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

Posted: 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: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 14 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: