
-----------------------------------
Original
Mon May 11, 2009 12:42 pm

MY first game- problems
-----------------------------------
Hi, I'm new to turing and i'm trying to make a game where homer simpson has to try to collect the falling donuts, and to avoid the flander's heads. I have two problems, my game is getting very flashy (flickery) and i dont understand how to work the collision detection between the donuts and homer simpson.

Thanks, here is the code  8-) 



var x, y : int
x := 100

var movex : int
var movec : int
var homer : int := Pic.FileNew ("homer.bmp")

y := 100

var chars : array char of boolean
process donutfall
    loop

        randint (movec, 0, 255)
        randint (movex, 0, maxx)

        for decreasing i : maxy .. 0 by 15

            Draw.FillOval (movex, i, 20, 20, movec)
            Draw.FillOval (movex, i, 7, 7, white)
            delay (20)
            cls
            View.UpdateArea (0, 0, 500, 400)
            if i 600 then
            x:= 600
            end if
            Pic.Draw (homer, x, y, 0)
        end if
        if chars (KEY_LEFT_ARROW) then
            x := x - 6
          
            if x < 0 then
            x:= 0
            end if
           
        end if
        if chars (KEY_DOWN_ARROW) then
            y := y - 6
            if y < 0 then
                y := 0
            end if
            Pic.Draw (homer, x, y, 0)
              end if
       


        Pic.Draw (homer, x, y, 0)
        delay (15)
        cls
        View.UpdateArea (0, 0, 500, 400)
    end loop
end homermove

fork donutfall
homermove

-----------------------------------
Tony
Mon May 11, 2009 12:53 pm

RE:MY first game- problems
-----------------------------------
to use [tdoc]View.Update[/tdoc] you need to set your view to the offscreenonly mode first. Though the use of processes breaks it anyway, so it will still flash, or simply not draw certain parts at all.

-----------------------------------
milkislife
Mon May 11, 2009 1:00 pm

RE:MY first game- problems
-----------------------------------
for donut detection, I suggest the comman whatdotcolor.
for example: if x and y are bottem left corner

Use that in an if statement.

if whatdotcolor(x+(halfway through homer),y+(height of homer + 1) = (color of donut) then

That there ^^ would check 1 above the middle top of homer. If it equaled the color of the donut then you could have score := score + 1

-----------------------------------
Tony
Mon May 11, 2009 1:13 pm

Re: RE:MY first game- problems
-----------------------------------
I suggest the comman whatdotcolor.
Don't listen to milkislife. If you know the position where to check for colours, you can easily just calculate the distance and see if two points are close enough to collide.

-----------------------------------
Dusk Eagle
Mon May 11, 2009 2:05 pm

Re: RE:MY first game- problems
-----------------------------------

If you know the position where to check for colours, you can easily just calculate the distance and see if two points are close enough to collide.

I'm pretty sure people have helped you with this twice before, so look there. Also, *ask your teacher!* Having a real person right there to help you can be indispensable when you are completely new to something (such as programming).

-----------------------------------
Original
Mon May 11, 2009 5:45 pm

Re: MY first game- problems
-----------------------------------
So is there any other ways i can run this without using processes? Because my picture wouldn't appear at the same time the donuts fall if i dont use the command process. And View.Update doesnt work if i use processes.

-----------------------------------
Tony
Mon May 11, 2009 5:55 pm

RE:MY first game- problems
-----------------------------------
You don't need processes, just use a single "main-loop" structure
[code]
loop
   % get input
   % act on input
   % update graphics
end loop
[/code]

-----------------------------------
Original
Mon May 11, 2009 8:15 pm

Re: MY first game- problems
-----------------------------------
I tried it with one loop but homer keeps appearing after the donuts fall down. After the new donut appears, the picture of homer goes away. I cant get homer's picture to run seperately.

-----------------------------------
Dusk Eagle
Mon May 11, 2009 8:27 pm

Re: MY first game- problems
-----------------------------------
We need code of what you've attempted if anyone is going to help you. Be sure to format it like this:

%%%code here%%%

[/code]
