So i am working on a game that is block based and i finnally got the camera stuff down only to find that no matter what i cant actually determine where the box actaully goes. Is there a command for this or something becuase it doesnt want to go to a certain spot. Also, if anyone could help me with making multiple blocks that would be nice. I know its probably a for loop but i dont know.
If you want to see the game in action just go here:
The Building Game
here is the source code:
Rem Project: Builder Game
Rem Created: Friday, February 14, 2014
Rem ***** Main Source File *****
hide mouse
load image "Dirt.bmp", 2
load image "Hammer.bmp", 1
load image "Character right.bmp", 3
load image "Character left.bmp", 4
load image "Stone.bmp", 5
global selectedblock as byte = 0
global stringselectedblock as string = "Delete"
global xpos as integer = 500
global ypos as integer = 500
direction as byte = 3
cls rgb(0, 0, 0)
Sync on
sync rate 70
make camera 1
position camera 1, xpos, ypos, 30
make matrix 1,1152,1024,20,20
prepare matrix texture 1,2,1,1
position matrix 1,0,0,0
update matrix 1
XRotate Camera 1, 75
do
set camera to follow 1, xpos, 100, ypos, 0, 100, 300, 1, 0
sync
// displaying the location of the character
text 5, 5, str$(xpos)
text 5, 15, str$(ypos)
// creation and movement of the character
// determine what key was pressed and orient the sprite accordingly
if keystate(17) = 1 then inc ypos, 3 //up
if keystate(32) = 1
inc xpos, 3
direction = 3
endif //left
if keystate(30) = 1
dec xpos, 3
direction = 4 //right
endif
if keystate(31) = 1 then dec ypos, 3 //down
// print the sprite
sprite 1, screen width()/2, screen height()/2, direction
//make the limits of the world so the player cant walk off
if ypos < 32 then inc ypos, 3
if ypos > 1058 then dec ypos, 3
if xpos < -15 then inc xpos, 3
if xpos > 1128 then dec xpos, 3
// the text and inventory system
if scancode() = 2 then selectedblock = 0
if scancode() = 3 then selectedblock = 1
if scancode() = 4 then selectedblock = 2
text 1, 10, " " + stringselectedblock
if selectedblock = 0
stringselectedblock = "Delete"
endif
if selectedblock = 1
stringselectedblock = "Stone Brick"
endif
if selectedblock = 2
stringselectedblock = "Dirt"
endif
//make the block appear near the mouse
if selectedblock = 2 then paste image 2, mousex(), mousey()
if selectedblock = 1 then paste image 5, mousex(), mousey()
// make the hammer not stick around when a different item is selected
if selectedblock = 0
sprite 2, mousex(), mousey(), 1
else
sprite 2, -400, -400, 1
endif
if selectedblock = 1 and scancode() = 28
global objectnumber as byte = 6
make object box objectnumber, 100, 100, 100
texture object objectnumber, 5
inc objectnumber
endif
loop
Thanks for any help in advance and if i could make anything better please let me know
https://www.mediafire.com/?htl9cg34jaxq0cphttp://www.mediafire.com/download/htl9cg34jaxq0cp/Building_Game.zip
-FishCube-