
-----------------------------------
yusong
Fri Jan 11, 2008 3:25 pm

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)

-----------------------------------
Tony
Fri Jan 11, 2008 4:00 pm

RE:Pictures
-----------------------------------
not quite in this way. That's a variable pointing to the picture, so instead of just

fireOrb := Pic.New()
waterOrb := Pic.New()

you should also have something like

elementOrb := fireOrb

and then you can always Pic.Draw(elementOrb), and later change what that particular element variable points to.

-----------------------------------
yusong
Fri Jan 11, 2008 5:02 pm

RE:Pictures
-----------------------------------
kk, thank you for the help.

-----------------------------------
yusong
Fri Jan 11, 2008 5:06 pm

RE:Pictures
-----------------------------------
Also, I would like this orb to move to the point I click on the map, how would I do that?

-----------------------------------
Sean
Fri Jan 11, 2008 5:08 pm

Re: Pictures
-----------------------------------
Are you saying, redraw the picture there?

-----------------------------------
Tony
Fri Jan 11, 2008 5:12 pm

RE:Pictures
-----------------------------------

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()

-----------------------------------
shakin cookie
Fri Jan 11, 2008 5:13 pm

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)

-----------------------------------
Sean
Fri Jan 11, 2008 5:17 pm

Re: Pictures
-----------------------------------
Yes, use mouse_x, mouse_y then if button is pressed, clear screen and redraw orb where mouse_x is.

-----------------------------------
yusong
Fri Jan 11, 2008 5:29 pm

RE:Pictures
-----------------------------------
No, I mean moving it across the screen, as in like a magic spell moving across the screen.
Sry for the confusion.

-----------------------------------
Tony
Fri Jan 11, 2008 5:48 pm

RE:Pictures
-----------------------------------
use a for-loop

-----------------------------------
yusong
Fri Jan 11, 2008 5:49 pm

RE:Pictures
-----------------------------------
What do you mean?

-----------------------------------
Nick
Fri Jan 11, 2008 6:53 pm

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?

-----------------------------------
yusong
Fri Jan 11, 2008 7:38 pm

RE:Pictures
-----------------------------------
So... How do i do say, from one point to another, that is not on a line or diagonal?

-----------------------------------
Nick
Fri Jan 11, 2008 7:41 pm

RE:Pictures
-----------------------------------
hmmm I'll see if I can find some old code that you can learn from

EDIT:

found some

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

-----------------------------------
yusong
Fri Jan 11, 2008 8:13 pm

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?

-----------------------------------
Nick
Fri Jan 11, 2008 8:22 pm

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

-----------------------------------
yusong
Sun Jan 13, 2008 5:12 pm

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

-----------------------------------
Saad
Sun Jan 13, 2008 6:14 pm

RE:Pictures
-----------------------------------
Might I suggest using trig, rather then the equation of a line. Also you probably are stuck in a loop.

-----------------------------------
yusong
Sun Jan 13, 2008 6:49 pm

RE:Pictures
-----------------------------------
Oh, Ok, Thanks Guys.

-----------------------------------
yusong
Sun Jan 13, 2008 7:15 pm

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:


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.

-----------------------------------
Nick
Sun Jan 13, 2008 8:03 pm

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

-----------------------------------
yusong
Sun Jan 13, 2008 8:50 pm

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?

-----------------------------------
yusong
Mon Jan 14, 2008 8:57 pm

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?

-----------------------------------
Saad
Mon Jan 14, 2008 9:05 pm

RE:Pictures
-----------------------------------
Although it was a side point, trig is basically a set of ratios in a triangle relating to angles, I suggest [url=http://www.clarku.edu/~djoyce/trig/]this as a good tutorial. Also trig is taught it grade 10 ;)

-----------------------------------
yusong
Fri Feb 01, 2008 3:45 pm

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?

-----------------------------------
Nick
Fri Feb 01, 2008 3:51 pm

RE:Pictures
-----------------------------------
1) do not use processes
2) only use a single View.Update
3) could you post the error message?

-----------------------------------
yusong
Fri Feb 01, 2008 4:10 pm

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?

-----------------------------------
A.J
Fri Feb 01, 2008 5:06 pm

Re: Pictures
-----------------------------------
just make sure you keep redrawing the picture (show me your code and i'll see what's wrong with it)
