Computer Science Canada

Pictures

Author:  yusong [ Fri Jan 11, 2008 3:25 pm ]
Post subject:  Pictures

I am making a game and there is one part where depending on the element that the player picks, a different coloured orb is drawn.

So it would be like this if your element was Fire
Pic.Draw (FireOrb, CharX, CharY, picCopy)

But what if the element was say, water, but i dont want to do
Pic.Draw (WaterOrb, CharX, CharY, picCopy)

Is there a way to do something like this?
Pic.Draw (Element + Orb, CharX, CharY, picCopy)

Author:  Tony [ Fri Jan 11, 2008 4:00 pm ]
Post subject:  RE:Pictures

not quite in this way. That's a variable pointing to the picture, so instead of just
code:

fireOrb := Pic.New()
waterOrb := Pic.New()

you should also have something like
code:

elementOrb := fireOrb

and then you can always Pic.Draw(elementOrb), and later change what that particular element variable points to.

Author:  yusong [ Fri Jan 11, 2008 5:02 pm ]
Post subject:  RE:Pictures

kk, thank you for the help.

Author:  yusong [ Fri Jan 11, 2008 5:06 pm ]
Post subject:  RE:Pictures

Also, I would like this orb to move to the point I click on the map, how would I do that?

Author:  Sean [ Fri Jan 11, 2008 5:08 pm ]
Post subject:  Re: Pictures

Are you saying, redraw the picture there?

Author:  Tony [ Fri Jan 11, 2008 5:12 pm ]
Post subject:  RE:Pictures

Quote:

Pic.Draw (Element + Orb, CharX, CharY, picCopy)

set your CharX and CharY to the location of the mouse. You can get the coordinates of the latter with Mouse.Where()

Author:  shakin cookie [ Fri Jan 11, 2008 5:13 pm ]
Post subject:  RE:Pictures

also, you could PicMerge the element colour and the orb, or use turing's new picBlend

Pic.DrawSpecial(200,100,picCopy,picBlend,100)

Author:  Sean [ Fri Jan 11, 2008 5:17 pm ]
Post subject:  Re: Pictures

Yes, use mouse_x, mouse_y then if button is pressed, clear screen and redraw orb where mouse_x is.

Author:  yusong [ Fri Jan 11, 2008 5:29 pm ]
Post subject:  RE:Pictures

No, I mean moving it across the screen, as in like a magic spell moving across the screen.
Sry for the confusion.

Author:  Tony [ Fri Jan 11, 2008 5:48 pm ]
Post subject:  RE:Pictures

use a for-loop

Author:  yusong [ Fri Jan 11, 2008 5:49 pm ]
Post subject:  RE:Pictures

What do you mean?

Author:  Nick [ Fri Jan 11, 2008 6:53 pm ]
Post subject:  RE:Pictures

for x:orbx.. mousex
orbx:=mousex
end for

Tony wouldn't it be better to rather increase the orb x and y each run through the main loop to make it look cleaner?

Author:  yusong [ Fri Jan 11, 2008 7:38 pm ]
Post subject:  RE:Pictures

So... How do i do say, from one point to another, that is not on a line or diagonal?

Author:  Nick [ Fri Jan 11, 2008 7:41 pm ]
Post subject:  RE:Pictures

hmmm I'll see if I can find some old code that you can learn from

EDIT:

found some

Turing:
process moveGuy1
    if chara (1) = true then
        anox := x%this is old code I'm sorry for the
        anoy := y%poor structure and x and y are mouse location
        loop     %also you probably don't want a process sso try to switch into a procedure
            if anox > movex then
                movex := movex + 1
            elsif anox < movex then
                movex := movex - 1
            end if
            if anoy > movey then
                movey := movey + 1
            elsif anoy < movey then
                movey := movey - 1
            end if
            exit when movex = anox and movey = anoy
            %delay (2)
        end loop
    end if
    onlyOnce := false
end moveGuy1


also please note I no longer write like this and cannot believe I ever had :S

Author:  yusong [ Fri Jan 11, 2008 8:13 pm ]
Post subject:  RE:Pictures

kk, THX
but, it is a 2D Tile game, so, whenever I click, it just stops and the pic does not show.
how do i stop that?

Author:  Nick [ Fri Jan 11, 2008 8:22 pm ]
Post subject:  RE:Pictures

the only things I can think of are

you are stuck in a loop somewhere and cannot get out

or

you may have forgot a View.Update

Author:  yusong [ Sun Jan 13, 2008 5:12 pm ]
Post subject:  RE:Pictures

Instead of the one momop suggested, wouldn't the equation of a line work too?

Y = (Point1 Y - Point2 Y) / (Point1 X - Point2 X) * X - Point2 X + Point2 Y

Author:  Saad [ Sun Jan 13, 2008 6:14 pm ]
Post subject:  RE:Pictures

Might I suggest using trig, rather then the equation of a line. Also you probably are stuck in a loop.

Author:  yusong [ Sun Jan 13, 2008 6:49 pm ]
Post subject:  RE:Pictures

Oh, Ok, Thanks Guys.

Author:  yusong [ Sun Jan 13, 2008 7:15 pm ]
Post subject:  RE:Pictures

kk, so i tried the line equation thing, it sort of works, but i am still stuck in a loop.
My code goes like this:

Turing:

if Clicked then

        loop

            NewY := ceil ((CharY - MY) / (CharX - MX) * (CharX + NewX) - MX + MY)
            Pic.Draw (ElementalOrb, NewY, NewX, picMerge)

            exit when NewX = MX and NewY = MY

            if MX > CharX then
                NewX += 1
            elsif MX < CharX then
                NewX -= 1
            end if

        end loop

    end if



So, if you click somewhere it draws the thing, but how do i get out of the loop, cause everytime i click, it jusst stops.

Author:  Nick [ Sun Jan 13, 2008 8:03 pm ]
Post subject:  RE:Pictures

make clicked a boolean varible
if mouse button clicked then clicked = true and MX and MY = mx and my

then get rid of the loop and make exit when into a if [condition] then clicked = flase

Author:  yusong [ Sun Jan 13, 2008 8:50 pm ]
Post subject:  RE:Pictures

Wait, what?
So, get rid of the loop, okay.
Clicked is a boolean variable.
And make 2 new vaiables called mx and my, so when mouse is clicked, mx=MX and my=MY.
get rid of exit when and make it and if statement, so, if Cilicked = false then exit out of the main loop.
Did i get that right?

Author:  yusong [ Mon Jan 14, 2008 8:57 pm ]
Post subject:  RE:Pictures

Ok, Saad, I haven't studied Trig yet, I think I am doing it next year, so, would you plz explain it to me?

Author:  Saad [ Mon Jan 14, 2008 9:05 pm ]
Post subject:  RE:Pictures

Although it was a side point, trig is basically a set of ratios in a triangle relating to angles, I suggest this as a good tutorial. Also trig is taught it grade 10 Wink

Author:  yusong [ Fri Feb 01, 2008 3:45 pm ]
Post subject:  RE:Pictures

KK, so I got it to work with the equation of a line cause I am too noob to use Trig yet, but now, the projectile flickers and if you move the guy while you shoot, the crashes, any suggestions guys?

Author:  Nick [ Fri Feb 01, 2008 3:51 pm ]
Post subject:  RE:Pictures

1) do not use processes
2) only use a single View.Update
3) could you post the error message?

Author:  yusong [ Fri Feb 01, 2008 4:10 pm ]
Post subject:  RE:Pictures

NVM, I fixed the error part, but, and took out the extra View.Update, but now when I move, and shoot, the projectile curves and doesnot go straight, any way to fix that and add multiple projectiles?

Author:  A.J [ Fri Feb 01, 2008 5:06 pm ]
Post subject:  Re: Pictures

just make sure you keep redrawing the picture (show me your code and i'll see what's wrong with it)


: