Computer Science Canada

Game help (moving circle)

Author:  Azzy123 [ Sat May 09, 2009 1:15 pm ]
Post subject:  Game help (moving circle)

What is it you are trying to achieve?
I need to make it so that when my bigger yellow circle passes over the smaller circles, the smaller circles completely disappear- currently only parts of them are erased.


What is the problem you are having?
I have the distance formula, but no matter where I put it in my code, it's never called on/ never works.

Describe what you have tried to solve this problem
I've tried changing the formula a bit. I've also placed it nearly everywhere in my code.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
I've tried using this as my formula:
Turing:

if sqrt ((x - a) ** 2 + (y - b) ** 2) <= (radius + 5) then
drawfilloval (a, b, 5, 5, black)
end if


and then I put it under the " %redcookie" part of my code. I just need to make one circle (cookie) get eaten.

Turing:


var chars : array char of boolean
var x, y, a, b, c, d, e, f, g, h, i, j : int
var radius : int := 10
var step : int := 2
var counter : int := 0
var isredcookie, isgreencookie, isorangecookie, iscyancookie, ismagentacookie : boolean := false

View.Set ("graphics, nobuttonbar,offscreenonly")
colorback (16)
cls

x := maxx div 2
y := maxy div 2

loop
    Input.KeyDown (chars)
    drawfilloval (x, y, radius, radius, 16)
    % UP-----------------------------------------------------
    if chars (KEY_UP_ARROW) and y <= maxy - 14 then

        y := y + step
    end if
    % DOWN---------------------------------------------------
    if chars (KEY_DOWN_ARROW) and y >= (0 + 14) then

        y := y - step
    end if
    % LEFT---------------------------------------------------
    if chars (KEY_LEFT_ARROW) and (x >= 0 + 11) then

        x := x - step
    end if
    % RIGHT--------------------------------------------------
    if chars (KEY_RIGHT_ARROW) and x <= (maxx - 11) then

        x := x + step
    end if
    drawfilloval (x, y, radius, radius, 14)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %redcookie
    if counter >= 500 then
        if isredcookie then
            drawfilloval (a, b, 5, 5, 16)



            isredcookie := false
        else
            randint (a, 5, maxx - 5)
            randint (b, 5, maxy - 5)
            drawfilloval (a, b, 5, 5, brightred)

            isredcookie := true


        end if
        counter := 0
    else
        counter := counter + 1
    end if
    %greencookie
    if counter >= 500 then
        if isgreencookie then
            drawfilloval (c, d, 5, 5, 16)
            isgreencookie := false
        else
            randint (c, 5, maxx - 5)
            randint (d, 5, maxy - 5)
            drawfilloval (c, d, 5, 5, brightgreen)
            isgreencookie := true
        end if
        counter := 0
    else
        counter := counter + 1

    end if

    %orangecookie
    if counter >= 500 then
        if isorangecookie then
            drawfilloval (e, f, 5, 5, 16)
            isorangecookie := false
        else
            randint (e, 5, maxx - 5)
            randint (f, 5, maxy - 5)
            drawfilloval (e, f, 5, 5, 42)
            isorangecookie := true
        end if
        counter := 0
    else

        counter := counter + 1
    end if
    %cyancookie
    if counter >= 500 then
        if iscyancookie then
            drawfilloval (g, h, 5, 5, 16)
            iscyancookie := false
        else
            randint (g, 5, maxx - 5)
            randint (h, 5, maxy - 5)
            drawfilloval (g, h, 5, 5, 52)
            iscyancookie := true
        end if
        counter := 0
    else
        counter := counter + 1
    end if
    %magentacookie
    if counter >= 500 then
        if ismagentacookie then
            drawfilloval (i, j, 5, 5, 16)
            ismagentacookie := false
        else
            randint (i, 5, maxx - 5)
            randint (j, 5, maxy - 5)
            drawfilloval (i, j, 5, 5, 36)
            ismagentacookie := true
        end if
        counter := 0
    else
        counter := counter + 1
    end if

    delay (10)


    View.Update

end loop



Please specify what version of Turing you are using
4.1

Edit: Sorry if it's a bit messy / impractical. It's my first attempt and I don't want to change it.

Author:  Azzy123 [ Sat May 09, 2009 3:24 pm ]
Post subject:  RE:Game help (moving circle)

Bump.. This is urgent, thanks.

Author:  Kharybdis [ Sat May 09, 2009 5:22 pm ]
Post subject:  RE:Game help (moving circle)

Your problem is that when your big circle moves over a small one, the trail of the big circle (you're moving it by increasing/decreasing its x and y position) is overlapping the smaller circle.

To fix it, one way to do it (albeit not an impressive way) is when the x and y of the big circle are in the range defined by the small cookie (of x and y), then assign that small cookie to be black instead of its original colour.

You can use the whatdotcolor function to do this, although i don't think it would be that efficient.

Author:  Azzy123 [ Sat May 09, 2009 6:13 pm ]
Post subject:  RE:Game help (moving circle)

Er yeah. As I stated in my original post, that's what I've been trying to do. But it won't work. No idea why.

I've been trying to use
Turing:
if sqrt ((x - a) ** 2 + (y - b) ** 2) <= (radius + 5) then
drawfilloval (a, b, 5, 5, black)
end if

Author:  OneTwo [ Sat May 09, 2009 6:58 pm ]
Post subject:  Re: Game help (moving circle)

Hey there, I've found a solution for you. Your current formula does not work, I haven't really thought of why it doesnt work but I made a solution for you.

Solution:

Here is a simple formula that will solve your problem, change a, b accordingly:

code:
   
if ((x + y) - (a + b) < 10) and ((x+y) - (a-b) > - 10) then
      drawfilloval (a, b, 5, 5, 16)
      a := 0
      b := 0
end if


Explanation:

code:
if ((x + y) - (a + b) < 10) and ((x+y) - (a-b) > - 10) then


This is a simple formula, it gets the sum of the center coordinates of your yellow oval and the centre co-ordinates of your red dot. It then substracts it from each other. It then checks whether the difference is less than 10 or - 10 (10 is the radius of your yellow oval).

code:
drawfilloval (a, b, 5, 5, 16)
      a := 0
      b := 0


When your condition has been met, it will draw another oval over your red dot making it disappear. A and B is set to 0 so that you don't see a grey circle over your yellow oval. Comment out a := 0 and b := 0 and you'll see what I mean.

Well that is all, hopefully I've helped you. : D

Author:  TheGuardian001 [ Sat May 09, 2009 7:02 pm ]
Post subject:  Re: Game help (moving circle)

but you're only drawing it black if it disappears on its own (after the timer).

what you need to do is check if the big yellow circle has hit the cookie, then set isredcookie (or whatever colour cookie) to false.

in pseudo code
Turing:


if player hit redcookie then
    isredcookie := false
end if

if player hit greencookie then
    isgreencookie := false
end if


and so on.
if you don't know how to do collision detection, I suggest you look
here
for square collisions (less effective in this case, but easier), or
here
for circular collision detection (a bit more complicated, but more accurate)

Edit: aw.... ninja'd by OneTwo

Author:  OneTwo [ Sat May 09, 2009 7:19 pm ]
Post subject:  Re: Game help (moving circle)

Sorry very small mistake,

code:
if ((x + y) - (a + b) < 10) and ((x+y) - (a-b) > - 10) then
      drawfilloval (a, b, 5, 5, 16)
      a := 0
      b := 0
end if


That should read as

code:
if ((x + y) - (a + b) < 10) and ((x+y) - (a+b) > - 10) then
      drawfilloval (a, b, 5, 5, 16)
      a := 0
      b := 0
end if


Mistake:
((x+y) - (a-b) > - 10
Corrected:
((x+y) - (a+b) > - 10

Author:  Azzy123 [ Sat May 09, 2009 7:49 pm ]
Post subject:  RE:Game help (moving circle)

Hi, sorry, either method still does not work. Where in the code would I need to put it? Thanks a lot for the help so far. Smile

Author:  OneTwo [ Sat May 09, 2009 8:39 pm ]
Post subject:  Re: Game help (moving circle)

Hey, the code works fine as I have just tested it. As for the location of the code, you can put it anywhere so long as it is executed every single time your object (yellow oval) moves.

Example: it can be right after "loop ..." or even right before "end loop"

code:
loop

<CONDITIONAL CODE HERE>

    Input.KeyDown (chars)
    drawfilloval (x, y, radius, radius, 16)
    % UP-----------------------------------------------------
    if chars (KEY_UP_ARROW) and y <= maxy - 14 then

        y := y + step
    end if
    % DOWN---------------------------------------------------
    if chars (KEY_DOWN_ARROW) and y >= (0 + 14) then

        y := y - step
    end if
    % LEFT---------------------------------------------------
    if chars (KEY_LEFT_ARROW) and (x >= 0 + 11) then

        x := x - step
    end if

...


OR


code:
...

  elsif ((x + y) - (g + h) < 20) and ((x+y) - (g+h) > - 20) then
      drawfilloval (g, h, 5, 5, 16)
      g := 0
      h := 0 
  elsif ((x + y) - (i + j) < 20) and ((x+y) - (i + j) > - 20) then
      drawfilloval (i, j, 5, 5, 16)
      i := 0
      j := 0 
    end if


<CONDITIONAL CODE HERE>
   
    delay (10)
    View.Update

end loop


Also note that you must change the variables(a, b) for it to work for the other cookies if you haven't already done so.

Author:  Azzy123 [ Sat May 09, 2009 8:57 pm ]
Post subject:  RE:Game help (moving circle)

Hmmmmmmm. I have no idea why mine isn't working. I've done everything you've said, and I understand your formula.. but it the cookie still isn't being eaten.

:s My brain feels like liquid. Thanks for your patience..

Author:  OneTwo [ Sat May 09, 2009 9:25 pm ]
Post subject:  Re: Game help (moving circle)

Hey, I added my code in to yours and here's the result:

I just changed the BG to gray, no worries you could change it to whatever you want.


Result:
code:
var chars : array char of boolean
var x, y, a, b, c, d, e, f, g, h, i, j : int := 0
var radius : int := 10
var step : int := 2
var counter : int := 0
var isredcookie, isgreencookie, isorangecookie, iscyancookie, ismagentacookie : boolean := false

View.Set ("graphics, nobuttonbar,offscreenonly")
colorback (24)
cls

x := maxx div 2
y := maxy div 2

loop
    Input.KeyDown (chars)
    drawfilloval (x, y, radius, radius, 24)
    % UP-----------------------------------------------------
    if chars (KEY_UP_ARROW) and y <= maxy - 14 then

        y := y + step
    end if
    % DOWN---------------------------------------------------
    if chars (KEY_DOWN_ARROW) and y >= (0 + 14) then

        y := y - step
    end if
    % LEFT---------------------------------------------------
    if chars (KEY_LEFT_ARROW) and (x >= 0 + 11) then

        x := x - step
    end if
    % RIGHT--------------------------------------------------
    if chars (KEY_RIGHT_ARROW) and x <= (maxx - 11) then

        x := x + step
    end if
    drawfilloval (x, y, radius, radius, 14)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %redcookie
    if counter >= 500 then
        if isredcookie then
            drawfilloval (a, b, 5, 5, 24)



            isredcookie := false
        else
            randint (a, 5, maxx - 5)
            randint (b, 5, maxy - 5)
            drawfilloval (a, b, 5, 5, brightred)

            isredcookie := true


        end if
        counter := 0
    else
        counter := counter + 1
    end if
    %greencookie
    if counter >= 500 then
        if isgreencookie then
            drawfilloval (c, d, 5, 5, 24)
            isgreencookie := false
        else
            randint (c, 5, maxx - 5)
            randint (d, 5, maxy - 5)
            drawfilloval (c, d, 5, 5, brightgreen)
            isgreencookie := true
        end if
        counter := 0
    else
        counter := counter + 1

    end if

    %orangecookie
    if counter >= 500 then
        if isorangecookie then
            drawfilloval (e, f, 5, 5, 24)
            isorangecookie := false
        else
            randint (e, 5, maxx - 5)
            randint (f, 5, maxy - 5)
            drawfilloval (e, f, 5, 5, 42)
            isorangecookie := true
        end if
        counter := 0
    else

        counter := counter + 1
    end if
    %cyancookie
    if counter >= 500 then
        if iscyancookie then
            drawfilloval (g, h, 5, 5, 24)
            iscyancookie := false
        else
            randint (g, 5, maxx - 5)
            randint (h, 5, maxy - 5)
            drawfilloval (g, h, 5, 5, 52)
            iscyancookie := true
        end if
        counter := 0
    else
        counter := counter + 1
    end if
    %magentacookie
    if counter >= 500 then
        if ismagentacookie then
            drawfilloval (i, j, 5, 5, 24)
            ismagentacookie := false
        else
            randint (i, 5, maxx - 5)
            randint (j, 5, maxy - 5)
            drawfilloval (i, j, 5, 5, 36)
            ismagentacookie := true
        end if
        counter := 0
    else
        counter := counter + 1
    end if
Text.Locate (1,1)
put (x+y) - (a+b), ",", (x+y) - (c+d), ",", (x+y) - (e + f), ",", (x+y) - (g + h), ",", (x+y) - (i + j)   
   
if ((x + y) - (a + b) <= 10) and ((x+y) - (a+b) >= - 10) then
      drawfilloval (a, b, 5, 5, 24)
      a := 0
      b := 0
end if
if ((x + y) - (c + d) <= 10) and ((x+y) - (c+d) >= - 10) then
      drawfilloval (c, d, 5, 5, 24)
      c := 0
      d := 0
end if
if((x + y) - (e + f) <= 10) and ((x+y) - (e+f) >= - 10) then
      drawfilloval (e, f, 5, 5, 24)
      e := 0
      f := 0
end if
if ((x + y) - (g + h) <= 10) and ((x+y) - (g+h) >= - 10) then
      drawfilloval (g, h, 5, 5, 24)
      g := 0
      h := 0
end if
if ((x + y) - (i + j) <= 10) and ((x+y) - (i+j) >= -10) then
      drawfilloval (i, j, 5, 5, 24)
      i := 0
      j := 0
end if
   
    delay (10)
    View.Update

end loop


Also note the minor changes to the conditional:

From:

code:
if ((x + y) - (a + b) < 10) and ((x+y) - (a+b) > - 10) then


To:
code:
if ((x + y) - (a + b) <= 10) and ((x+y) - (a+b) >= - 10) then

Author:  Azzy123 [ Sat May 09, 2009 9:36 pm ]
Post subject:  RE:Game help (moving circle)

Hey, thanks a lot, but why is the timing so different? The cookies appear too quickly / slowly. Also, sometimes the red cookie appears at the bottom left of the screen (half appears on the screen and the other bit is cut off). The cookies seem to disappear randomly.

Edit: Yeah, they seem to disappear when I approach from their left sides.

Author:  OneTwo [ Sat May 09, 2009 10:05 pm ]
Post subject:  RE:Game help (moving circle)

It seems it has something to do with the way your counter works,so try experimenting with different ways to draw your random ovals. It's getting fairly late, i'll help you more tomorrow if that's fine with you.

Author:  Azzy123 [ Sat May 09, 2009 10:07 pm ]
Post subject:  RE:Game help (moving circle)

Yes, I'll keep working on it. Thank you so much.

Author:  OneTwo [ Sun May 10, 2009 12:13 pm ]
Post subject:  Re: Game help (moving circle)

Hey, it looks like my math was way off yesterday. Your formula is correct here is the more accurate code that should be used:

code:
var chars : array char of boolean
var x, y, a, b, c, d, e, f, g, h, i, j : int := 0
var radius : int := 10
var step : int := 2
var counter : int := 0
var isredcookie, isgreencookie, isorangecookie, iscyancookie, ismagentacookie : boolean := false

View.Set ("graphics, nobuttonbar,offscreenonly")
colorback (24)
cls

x := maxx div 2
y := maxy div 2

loop
    Input.KeyDown (chars)
    drawfilloval (x, y, radius, radius, 24)
    % UP-----------------------------------------------------
    if chars (KEY_UP_ARROW) and y <= maxy - 14 then

        y := y + step
    end if
    % DOWN---------------------------------------------------
    if chars (KEY_DOWN_ARROW) and y >= (0 + 14) then

        y := y - step
    end if
    % LEFT---------------------------------------------------
    if chars (KEY_LEFT_ARROW) and (x >= 0 + 11) then

        x := x - step
    end if
    % RIGHT--------------------------------------------------
    if chars (KEY_RIGHT_ARROW) and x <= (maxx - 11) then

        x := x + step
    end if
    drawfilloval (x, y, radius, radius, 14)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %redcookie
    if counter >= 500 then
        if isredcookie then
            drawfilloval (a, b, 5, 5, 24)



            isredcookie := false
        else
            randint (a, 5, maxx - 5)
            randint (b, 5, maxy - 5)
            drawfilloval (a, b, 5, 5, brightred)

            isredcookie := true


        end if
        counter := 0
    else
        counter := counter + 1
    end if
    %greencookie
    if counter >= 500 then
        if isgreencookie then
            drawfilloval (c, d, 5, 5, 24)
            isgreencookie := false
        else
            randint (c, 5, maxx - 5)
            randint (d, 5, maxy - 5)
            drawfilloval (c, d, 5, 5, brightgreen)
            isgreencookie := true
        end if
        counter := 0
    else
        counter := counter + 1

    end if

    %orangecookie
    if counter >= 500 then
        if isorangecookie then
            drawfilloval (e, f, 5, 5, 24)
            isorangecookie := false
        else
            randint (e, 5, maxx - 5)
            randint (f, 5, maxy - 5)
            drawfilloval (e, f, 5, 5, 42)
            isorangecookie := true
        end if
        counter := 0
    else

        counter := counter + 1
    end if
    %cyancookie
    if counter >= 500 then
        if iscyancookie then
            drawfilloval (g, h, 5, 5, 24)
            iscyancookie := false
        else
            randint (g, 5, maxx - 5)
            randint (h, 5, maxy - 5)
            drawfilloval (g, h, 5, 5, 52)
            iscyancookie := true
        end if
        counter := 0
    else
        counter := counter + 1
    end if
    %magentacookie
    if counter >= 500 then
        if ismagentacookie then
            drawfilloval (i, j, 5, 5, 24)
            ismagentacookie := false
        else
            randint (i, 5, maxx - 5)
            randint (j, 5, maxy - 5)
            drawfilloval (i, j, 5, 5, 36)
            ismagentacookie := true
        end if
        counter := 0
    else
        counter := counter + 1
    end if
   
   
if sqrt ((x - a) ** 2 + (y - b) ** 2) <= (radius + 5) then
        drawfilloval (a, b, 5, 5, 24)
        a := 0
        b := 0
   
end if
if sqrt ((x - c) ** 2 + (y - d) ** 2) <= (radius + 5) then
      drawfilloval (c, d, 5, 5, 24)
      c := 0
      d := 0
end if
if sqrt ((x - e) ** 2 + (y - f) ** 2) <= (radius + 5) then
      drawfilloval (e, f, 5, 5, 24)
      e := 0
      f := 0
end if
if sqrt ((x - g) ** 2 + (y - h) ** 2) <= (radius + 5) then
      drawfilloval (g, h, 5, 5, 24)
      g := 0
      h := 0
end if
if sqrt ((x - i) ** 2 + (y - j) ** 2) <= (radius + 5) then
      drawfilloval (i, j, 5, 5, 24)
      i := 0
      j := 0
end if
   
    delay (10)
    View.Update

end loop


I'm very sorry if I made you confused in any way.

Author:  Azzy123 [ Sun May 10, 2009 4:26 pm ]
Post subject:  RE:Game help (moving circle)

Ah, thank god. Works perfectly. I was wondering why my original formula wasn't working. Now it's glitch-free. Thanks!

Now I guess I'll change it a bit to my liking.

Author:  Azzy123 [ Sun May 10, 2009 4:38 pm ]
Post subject:  Re: Game help (moving circle)

In case you're interested, here's my near-final result:

Turing:

var a, b, c, d, e, f, g, h, i, j : int := 0        %Cookie positions
var x, y : int        %Bubble position
x := maxx div 2       %Start bubble from center
y := maxy div 2
var chars : array char of boolean       % Gives each key its own input value, doesn't wait for enter
var radius : int := 10         % Initial bubble radius
var step : int := 2            % Initial bubble speed (combined with delay)
var counter : int := 0         % Decides when cookies appear
var isredcookie, isgreencookie, isorangecookie, iscyancookie, ismagentacookie : boolean := false % Later checks if each cookie is true/false (on/off screen)


View.Set ("graphics, nobuttonbar,offscreenonly") % Set to graphics, remove toolbar from run window, reduce animation flickering
colorback (16)
cls



loop
    %KEY ENTRIES --------------------------------------------------------------------------------
    Input.KeyDown (chars)
    drawfilloval (x, y, radius, radius, 16)
    % Q to quit----------------------------------------------------------------
    if chars ('q') then
        quit
    end if
    % C to clear all cookies from screen---------------------------------------
    if chars ('c') then
        cls
    end if
    % R to reset bubble position-----------------------------------------------
    if chars ('r') then
        x := maxx div 2
        y := maxy div 2
    end if
    % up-----------------------------------------------------------------------
    if chars (KEY_UP_ARROW) and y <= maxy - radius then

        y := y + step
    end if
    % down---------------------------------------------------------------------
    if chars (KEY_DOWN_ARROW) and y >= (0 + radius) then

        y := y - step
    end if
    % left---------------------------------------------------------------------
    if chars (KEY_LEFT_ARROW) and (x >= 0 + radius) then

        x := x - step
    end if
    % right--------------------------------------------------------------------
    if chars (KEY_RIGHT_ARROW) and x <= (maxx - radius) then

        x := x + step
    end if
    drawfilloval (x, y, radius, radius, 14)


    %COOKIES ------------------------------------------------------------------------------------
    %redcookie-----------------------------------------------------------------
    if counter >= 500 then
        if isredcookie then
            drawfilloval (a, b, 5, 5, 16)
            isredcookie := false
        else
            randint (a, 5, maxx - 5)
            randint (b, 5, maxy - 5)
            drawfilloval (a, b, 5, 5, brightred)
            isredcookie := true
        end if
        counter := 0
    else
        counter := counter + 1
    end if
    %greencookie---------------------------------------------------------------
    if counter >= 500 then
        if isgreencookie then
            drawfilloval (c, d, 5, 5, 16)
            isgreencookie := false
        else
            randint (c, 5, maxx - 5)
            randint (d, 5, maxy - 5)
            drawfilloval (c, d, 5, 5, brightgreen)
            isgreencookie := true
        end if
        counter := 0
    else
        counter := counter + 1
    end if
    %orangecookie--------------------------------------------------------------
    if counter >= 500 then
        if isorangecookie then
            drawfilloval (e, f, 5, 5, 16)
            isorangecookie := false
        else
            randint (e, 5, maxx - 5)
            randint (f, 5, maxy - 5)
            drawfilloval (e, f, 5, 5, 42)
            isorangecookie := true
        end if
        counter := 0
    else

        counter := counter + 1
    end if
    %cyancookie----------------------------------------------------------------
    if counter >= 500 then
        if iscyancookie then
            drawfilloval (g, h, 5, 5, 16)
            iscyancookie := false
        else
            randint (g, 5, maxx - 5)
            randint (h, 5, maxy - 5)
            drawfilloval (g, h, 5, 5, 52)
            iscyancookie := true
        end if
        counter := 0
    else
        counter := counter + 1
    end if
    %magentacookie-------------------------------------------------------------
    if counter >= 500 then
        if ismagentacookie then
            drawfilloval (i, j, 5, 5, 16)
            ismagentacookie := false
        else
            randint (i, 5, maxx - 5)
            randint (j, 5, maxy - 5)
            drawfilloval (i, j, 5, 5, 36)
            ismagentacookie := true
        end if
        counter := 0
    else
        counter := counter + 1
    end if

    % COLLISIONS --------------------------------------------------------------------------------
    %redcookie-----------------------------------------------------------------
    if isredcookie and sqrt ((x - a) ** 2 + (y - b) ** 2) <= (radius + 5) then
        drawfilloval (a, b, 5, 5, 16)
        isredcookie := false
        a := 0
        b := 0
        radius := radius + 5          % Increases radius by 5px
    end if
    %greencookie---------------------------------------------------------------
    if isgreencookie and sqrt ((x - c) ** 2 + (y - d) ** 2) <= (radius + 5) then
        drawfilloval (c, d, radius + 25, radius + 25, 16)
        isgreencookie := false
        c := 0
        d := 0
        if radius not= 5 then         % Stops bubble from getting a '0' radius
            radius := radius - 5      % Decreases radius by 5px
        end if
    end if
    %orangecookie--------------------------------------------------------------
    if isorangecookie and sqrt ((x - e) ** 2 + (y - f) ** 2) <= (radius + 5) then
        drawfilloval (e, f, 5, 5, 16)
        isorangecookie := false
        e := 0
        f := 0
        step := step + 1              % Increases speed by 1px
    end if
    %cyancookie----------------------------------------------------------------
    if iscyancookie and sqrt ((x - g) ** 2 + (y - h) ** 2) <= (radius + 5) then
        drawfilloval (g, h, 5, 5, 16)
        iscyancookie := false
        g := 0
        h := 0
        if step not= 1 then           % Prevents speed from equaling '0'
            step := step - 1          % Decreases speed by 1px
        end if
    end if
    %magentacookie-------------------------------------------------------------
    if ismagentacookie and sqrt ((x - i) ** 2 + (y - j) ** 2) <= (radius + 5) then
        drawfilloval (i, j, 5, 5, 16)
        ismagentacookie := false
        i := 0
        j := 0
    end if

    delay (10)
    View.Update

end loop


Red = increases radius
Green = decreases radius
orange = increases speed
cyan = decreases speed
magenta = inverts keys -- doing it right now (and it's working Very Happy)

The only problem that exists now is that there seems to be some yellow residue that's left behind after the inflated yellow bubble passes over a green cookie.

Author:  Turing_Noob [ Sun May 10, 2009 5:05 pm ]
Post subject:  RE:Game help (moving circle)

post what you did for the magenta afterwards, i'm interested to see what you did for that since i wouldn't even know where to start if i had that assignment in other words i would be interested to see your finished assignment

Author:  Azzy123 [ Sun May 10, 2009 5:26 pm ]
Post subject:  Re: RE:Game help (moving circle)

Turing_Noob @ Sun May 10, 2009 5:05 pm wrote:
post what you did for the magenta afterwards, i'm interested to see what you did for that since i wouldn't even know where to start if i had that assignment in other words i would be interested to see your finished assignment


I was originally doing it one way, but the easiest way to do it is to append "-" before "step". This makes everything the opposite.


..If that makes sense to you.

Author:  Turing_Noob [ Sun May 10, 2009 5:29 pm ]
Post subject:  RE:Game help (moving circle)

i have no idea what your talking about, can you please post the code. I usually understand it better if it's in code

Author:  Azzy123 [ Sun May 10, 2009 5:32 pm ]
Post subject:  RE:Game help (moving circle)

Under the magenta bit, step:= -step.

Author:  Turing_Noob [ Sun May 10, 2009 5:33 pm ]
Post subject:  RE:Game help (moving circle)

can you post your finished code, it'll be easier for me to understand that way

Author:  Azzy123 [ Sun May 10, 2009 5:36 pm ]
Post subject:  RE:Game help (moving circle)

Er. Being my paranoid self, why are you so interested?

Author:  Turing_Noob [ Sun May 10, 2009 5:39 pm ]
Post subject:  RE:Game help (moving circle)

i'm just curious that's all you see i'm making a game to and it would be get if i could add a feature similar to that

Author:  Azzy123 [ Sun May 10, 2009 5:41 pm ]
Post subject:  RE:Game help (moving circle)

I'm very sorry, but if you need this code for your own project, just say so. You can't just walk in and copy + paste it to your own.

It's very straightforward. Under the magenta cookie part, make step:= -step.

I'm highly suspicious. Surprised

Author:  Turing_Noob [ Sun May 10, 2009 5:44 pm ]
Post subject:  RE:Game help (moving circle)

thanks for the help

Author:  OneTwo [ Sun May 10, 2009 5:58 pm ]
Post subject:  RE:Game help (moving circle)

Hey great job on the near-final product! I'm really liking it. For the yellow residue, you can do this:

Draw a black oval over the green cookie first, then draw a black oval over your yellow cookie. Reduce the radius of your yellow cookie, then redraw your yellow cookie.

Author:  Azzy123 [ Sun May 10, 2009 7:08 pm ]
Post subject:  RE:Game help (moving circle)

Works Very Happy


: