So i am making a game where you are running around a 2d plane and i need the camera to follow the player image as it moves. This might just involve moving the camera as the image moves but i really dont know. Im not good with 3d coding and this is really the first type of 3d thing ive done so yah.
Here is the 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
SET IMAGE COLORKEY 255, 255, 255
global selectedblock as byte = 0
global stringselectedblock as string = "Delete"
global xpos as integer = 30
global ypos as integer = 30
direction as byte = 3
Sync on
sync rate 60
do
sync
//make the camera follow the player
set camera to follow 30, 30, 0, 0, 10, 30, 1, 0
// making the background white
cls rgb(205, 133, 63)
// creation and movement of the character
// determine what key was pressed and orient the sprite accordingly
select scancode()
case 17
dec ypos, 3 //up
endcase
case 32
inc xpos, 3
direction = 3 //left
endcase
case 30
dec xpos, 3
direction = 4 //right
endcase
case 31
inc ypos, 3 //down
endcase
endselect
// print the sprite
sprite 1, xpos, ypos, direction
// the text and inventory system
//determine what blocks have what image
if block1 = 2 then paste image 2, 0, 0
if block2 = 2 then paste image 2, 64, 0
if block3 = 2 then paste image 2, 128, 0
if block4 = 2 then paste image 2, 192, 0
if block5 = 2 then paste image 2, 256, 0
if block6 = 2 then paste image 2, 320, 0
if block7 = 2 then paste image 2, 384, 0
if block8 = 2 then paste image 2, 448, 0
if block9 = 2 then paste image 2, 512, 0
if block10 = 2 then paste image 2, 576, 0
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"
endif
if selectedblock = 2
stringselectedblock = "Dirt"
endif
//placing blocks and defining blocks
if selectedblock = 2 then paste image 2, mousex(), mousey()
if mouseclick() = 1 and mousex() <= 64 and mousex() >=0 and mousey() <=64 and mousey() >= 0
if selectedblock = 2 then block1 = 2
if selectedblock = 0 then block1 = 0
endif
if mouseclick() = 1 and mousex() <= 128 and mousex() >=65 and mousey() <=64 and mousey() >=0
if selectedblock = 2 then block2 = 2
if selectedblock = 0 then block2 = 0
endif
if mouseclick() = 1 and mousex() <= 192 and mousex() >=129 and mousey() <=64 and mousey() >= 0
if selectedblock = 2 then block3 = 2
if selectedblock = 0 then block3 = 0
endif
if mouseclick() = 1 and mousex() <= 256 and mousex() >=194 and mousey() <=64 and mousey() >= 0
if selectedblock = 2 then block4 = 2
if selectedblock = 0 then block4 = 0
endif
if mouseclick() = 1 and mousex() <= 320 and mousex() >=258 and mousey() <=64 and mousey() >= 0
if selectedblock = 2 then block5 = 2
if selectedblock = 0 then block5 = 0
endif
if mouseclick() = 1 and mousex() <= 384 and mousex() >=322 and mousey() <=64 and mousey() >= 0
if selectedblock = 2 then block6 = 2
if selectedblock = 0 then block6 = 0
endif
if mouseclick() = 1 and mousex() <= 448 and mousex() >=386 and mousey() <=64 and mousey() >= 0
if selectedblock = 2 then block7 = 2
if selectedblock = 0 then block7 = 0
endif
if mouseclick() = 1 and mousex() <= 512 and mousex() >=450 and mousey() <=64 and mousey() >= 0
if selectedblock = 2 then block8 = 2
if selectedblock = 0 then block8 = 0
endif
if mouseclick() = 1 and mousex() <= 576 and mousex() >=514 and mousey() <=64 and mousey() >= 0
if selectedblock = 2 then block9 = 2
if selectedblock = 0 then block9 = 0
endif
if mouseclick() = 1 and mousex() <= 640 and mousex() >=578 and mousey() <=64 and mousey() >= 0
if selectedblock = 2 then block10 = 2
if selectedblock = 0 then block10 = 0
endif
if selectedblock = 0
sprite 2, mousex(), mousey(), 1
else
sprite 2, -400, -400, 1
endif
loop
i know its probably really inefficient but it sorta works. Also if anyone has any suggestions on how to make the building grid bigger and maybe expand the world off of the little screen that would be great. Thanks for the help ahead of time
Ok i think i did something, it is definitely better but now the question arises, how do i make the sprite be in space and not client side? Here is the new game running http://www.mediafire.com/download/htl9cg34jaxq0cp/Building_Game.zip
there are so many questions i have about this but lets just stick to making the character not client side eh?
-FishCube-