
-----------------------------------
windowsall
Mon May 09, 2005 10:32 am

Need help with whatdotcolor in my game
-----------------------------------
Hello ive been working on my game code named ROG its actually a pretty cool game but there have been problems with it as when i use whatdotcolor i can not move my character heres the code
its to much to upload and will put it on my server when i get back from school

import "Bsprite.tu"
setscreen ("graphics:640;480,nobuttonbar,position:center;center")
setscreen ("offscreenonly")
colorback (black)
color (yellow)
cls
locate (10, 10)
put " Loading . . ."
View.Update
var map : array 1 .. 2 of int
map (1) := Pic.FileNew ("farm.bmp")
map (2) := Pic.FileNew ("farmback.bmp")
var x, y : int := 20
var player : int := BSprite.New (x, y, "maincharacter.bmp")
var key : array char of boolean


Pic.Draw (map (2), 0, 0, picCopy)
Pic.Draw (map (1), 0, 0, picCopy)
View.Update

proc refresh
    Input.KeyDown (key)
    if key (KEY_LEFT_ARROW) and x > 10 and whatdotcolor (x - 10, y) = yellow then
        x := x - 4
        BSprite.Change ("maincharactersidel.bmp", player)

    end if
    if key (KEY_RIGHT_ARROW) and x < maxx - 10 and whatdotcolor (x + 10, y) = yellow then
        x += 4
        BSprite.Change ("maincharactersider.bmp", player)

    end if
    if key (KEY_UP_ARROW) and y < maxy - 25 and whatdotcolor (x, y - 4) = yellow then
        y += 4
        BSprite.Change ("maincharacterback.bmp", player)

    end if
    if key (KEY_DOWN_ARROW) and y > 3 and whatdotcolor (x, y - 4) = yellow
            then
        y -= 4
        BSprite.Change ("maincharacter.bmp", player)


    end if

end refresh
loop

    BSprite.Move (x, y, player)
    View.Update
    refresh
    delay (10)
end loop


-----------------------------------
jamonathin
Mon May 09, 2005 12:12 pm


-----------------------------------
I fixed your coding, here it is.  Check your collisions though, they don't work right.  Take a look at this tutorial to see how your program should be set up for this type of collision checking. import "BSprite.tu"
setscreen ("graphics:640;480,nobuttonbar,position:center;center")
setscreen ("offscreenonly")
colorback (black)
color (yellow)
cls
locate (10, 10)
put " Loading . . ."
View.Update
var map : array 1 .. 2 of int
var dir : int := 4
map (1) := Pic.FileNew ("farm.bmp")
map (2) := Pic.FileNew ("farmback.bmp")
var x, y : int := 20
var player : int := BSprite.New (x, y, "maincharacter.bmp")
var key : array char of boolean


proc refresh
    Input.KeyDown (key)
    Pic.Draw (map (2), 0, 0, picCopy)
    if key (KEY_LEFT_ARROW) and x > 10 and whatdotcolor (x - 10, y) = yellow then
        x := x - 4
        dir := 1
    end if
    if key (KEY_RIGHT_ARROW) and x < maxx - 10 and whatdotcolor (x + 10, y) = yellow then
        x += 4
        dir := 2
    end if
    if key (KEY_UP_ARROW) and y < maxy - 25 and whatdotcolor (x, y - 4) = yellow then
        y += 4
        dir := 3
    end if
    if key (KEY_DOWN_ARROW) and y > 3 and whatdotcolor (x, y - 4) = yellow then
        y -= 4
        dir := 4
    end if
    Pic.Draw (map (1), 0, 0, picCopy)
    if dir = 1 then
        BSprite.Change ("maincharactersidel.bmp", player)
    elsif dir = 2 then
        BSprite.Change ("maincharactersider.bmp", player)
    elsif dir = 3 then
        BSprite.Change ("maincharacterback.bmp", player)
    elsif dir = 4 then
        BSprite.Change ("maincharacter.bmp", player)
    end if
    View.Update
end refresh
loop

    BSprite.Move (x, y, player)
    refresh
    delay (10)
end loop

