SOLVED MODS CAN CLOSE IF THEY WANT
Hi im new to dark basic and for my first projecti decided to try make a terrain edtior. But i've Run into two problems already:
1) The First problem is the plane im drawing isnt draw as red even do i colored it red.
2)The second is The way im drawing the plane at the moment isn't the way i want it.Is ther a way to draw it by specifying the cordinates of each vertice.
Heres my code im surprised i got as far as i did without running into a problem:
mode=1 REM This changes the edit Mode 0=Vertex Edit 1=Tile Edit
xstep=800/80
ystep=600/60
xpos=0
ypos=0
last_up=0
last_down=0
last_left=0
last_right=0
last_num8=0
last_num2=0
SYNC ON REM Set the sync to on to control the screen refreshment manually
SYNC RATE 60 REM Set the sync rate(fps) to 60
MAKE MATRIX 1,800,600,80,60 REM Create a matrix(Terrain)
POSITION MATRIX 1,0,0,0 REM Position the matrix at point 0,0,0 in 3D Space
MAKE OBJECT SPHERE 1,2 REM Make a 3d Sphere to show the vertex currently being edited
COLOR OBJECT 1, RGB(255,0,0) REM Set the Colour of the 3d Sphere to Red
MAKE OBJECT PLANE 2,xstep,ystep REM Make a Plane to show the Tile currently being edited
ROTATE OBJECT 2,90,0,0 REM Position The plane so that it is flat
COLOR OBJECT 2,RGB(255,0,0) REM Color the plane Red
DO REM Start the main loop
WHILE mode=0 REM Vertex editor Loop
IF OBJECT VISIBLE(2)=1 THEN HIDE OBJECT 2
IF OBJECT VISIBLE(1)=0 THEN SHOW OBJECT 1
height=GET MATRIX HEIGHT (1,xpos,ypos) REM Get The Height of the Vertex Curently Selected
GOSUB keyboard_vertex REM Go to the keyboard_vertex bookmark
GOSUB check_values_vertex REM Go to the check_values_vertex bookmark
POSITION OBJECT 1,xpos*xstep,height,ypos*ystep REM place the Red Sphere Object at the position of the vertex currently being edited
POSITION CAMERA xpos*xstep,height+100,ypos*ystep-100 REM Position the camera
POINT CAMERA xpos*xstep,height,ypos*ystep REM Point the camera at the vertex being edited
UPDATE MATRIX 1 REM Updates the Matrix or Terrain
SYNC REM Sync to the Screen
ENDWHILE REM End of Vertex Editor Loop
WHILE mode=1 REM Vertex editor Loop
IF OBJECT VISIBLE(1)=1 THEN HIDE OBJECT 1
IF OBJECT VISIBLE(2)=0 THEN SHOW OBJECT 2
height=GET MATRIX HEIGHT (1,xpos,ypos) REM Get The Height of the Vertex Curently Selected
GOSUB keyboard_tile REM Go to the keyboard_tile bookmark
GOSUB check_values_tile REM Go to the check_values_tile bookmark
POSITION OBJECT 2,(xpos*xstep)+(xstep/2),height,(ypos*ystep)+(ystep/2) REM place the Red plane Object at the position of the vertex currently being edited
POSITION CAMERA xpos*xstep,height+100,ypos*ystep-100 REM Position the camera
POINT CAMERA xpos*xstep,height,ypos*ystep REM Point the camera at the vertex being edited
UPDATE MATRIX 1 REM Updates the Matrix or Terrain
SYNC REM Sync to the Screen
ENDWHILE REM End of Vertex Editor Loop
LOOP REM End of main loop
END REM End The Program
check_values_tile:
IF xpos<0 THEN xpos=0
IF xpos>79 THEN xpos=79
IF ypos<0 THEN ypos=0
IF ypos>59 THEN ypos=59
RETURN
check_values_vertex:
IF xpos<0 THEN xpos=0
IF xpos>80 THEN xpos=80
IF ypos<0 THEN ypos=0
IF ypos>60 THEN ypos=60
RETURN
keyboard_tile:
IF UPKEY()=1 AND last_up=0
INC ypos,1
last_up=1
ENDIF
IF UPKEY()=0 AND last_up=1 THEN last_up=0
IF DOWNKEY()=1 AND last_down=0
DEC ypos,1
last_down=1
ENDIF
IF DOWNKEY()=0 AND last_down=1 THEN last_down=0
IF RIGHTKEY()=1 AND last_right=0
INC xpos,1
last_right=1
ENDIF
IF RIGHTKEY()=0 AND last_right=1 THEN last_right=0
IF LEFTKEY()=1 AND last_left=0
DEC xpos,1
last_left=1
ENDIF
IF LEFTKEY()=0 AND last_left=1 THEN last_left=0
IF KEYSTATE(72)=1 AND last_num8=0
SET MATRIX HEIGHT 1,xpos,ypos,height+5
SET MATRIX HEIGHT 1,xpos+1,ypos,height+5
SET MATRIX HEIGHT 1,xpos,ypos+1,height+5
SET MATRIX HEIGHT 1,xpos+1,ypos+1,height+5
last_num8=1
ENDIF
IF KEYSTATE(72)=0 AND last_num8=1 THEN last_num8=0
IF KEYSTATE(80)=1 AND last_num2=0
SET MATRIX HEIGHT 1,xpos,ypos,height-5
SET MATRIX HEIGHT 1,xpos+1,ypos,height-5
SET MATRIX HEIGHT 1,xpos,ypos+1,height-5
SET MATRIX HEIGHT 1,xpos+1,ypos+1,height-5
last_num2=1
ENDIF
IF KEYSTATE(80)=0 AND last_num2=1 THEN last_num2=0
RETURN
keyboard_vertex:
IF UPKEY()=1 AND last_up=0
INC ypos,1
last_up=1
ENDIF
IF UPKEY()=0 AND last_up=1 THEN last_up=0
IF DOWNKEY()=1 AND last_down=0
DEC ypos,1
last_down=1
ENDIF
IF DOWNKEY()=0 AND last_down=1 THEN last_down=0
IF RIGHTKEY()=1 AND last_right=0
INC xpos,1
last_right=1
ENDIF
IF RIGHTKEY()=0 AND last_right=1 THEN last_right=0
IF LEFTKEY()=1 AND last_left=0
DEC xpos,1
last_left=1
ENDIF
IF LEFTKEY()=0 AND last_left=1 THEN last_left=0
IF KEYSTATE(72)=1 AND last_num8=0
SET MATRIX HEIGHT 1,xpos,ypos,height+5
last_num8=1
ENDIF
IF KEYSTATE(72)=0 AND last_num8=1 THEN last_num8=0
IF KEYSTATE(80)=1 AND last_num2=0
SET MATRIX HEIGHT 1,xpos,ypos,height-5
last_num2=1
ENDIF
IF KEYSTATE(80)=0 AND last_num2=1 THEN last_num2=0
RETURN
Fixed BOTH Problems but now i have another 1 When i press the space key its supposed to changed the edit mode can't find the problem can any1 help?
Heres the Updated Code
mode=1 REM This changes the edit Mode 0=Vertex Edit 1=Tile Edit
xstep=800/80
ystep=600/60
xpos=0
ypos=0
last_up=0
last_down=0
last_left=0
last_right=0
last_num8=0
last_num2=0
last_space=0
SYNC ON REM Set the sync to on to control the screen refreshment manually
SYNC RATE 60 REM Set the sync rate(fps) to 60
MAKE MATRIX 1,800,600,80,60 REM Create a matrix(Terrain)
POSITION MATRIX 1,0,0,0 REM Position the matrix at point 0,0,0 in 3D Space
MAKE OBJECT SPHERE 1,2 REM Make a 3d Sphere to show the vertex currently being edited
COLOR OBJECT 1, RGB(255,0,0) REM Set the Colour of the 3d Sphere to Red
REM MAKE OBJECT PLANE 2,xstep,ystep REM Make a Plane to show the Tile currently being edited
REM ROTATE OBJECT 2,270,0,0 REM Position The plane so that it is flat
REM COLOR OBJECT 2,RGB(255,0,0) REM Color the plane Red
DO REM Start the main loop
WHILE mode=0 REM Vertex editor Loop
IF OBJECT VISIBLE(1)=0 THEN SHOW OBJECT 1
height=GET MATRIX HEIGHT (1,xpos,ypos) REM Get The Height of the Vertex Curently Selected
GOSUB keyboard_vertex REM Go to the keyboard_vertex bookmark
GOSUB check_values_vertex REM Go to the check_values_vertex bookmark
GOSUB mode_change
POSITION OBJECT 1,xpos*xstep,height,ypos*ystep REM place the Red Sphere Object at the position of the vertex currently being edited
POSITION CAMERA xpos*xstep,height+100,ypos*ystep-100 REM Position the camera
POINT CAMERA xpos*xstep,height,ypos*ystep REM Point the camera at the vertex being edited
UPDATE MATRIX 1 REM Updates the Matrix or Terrain
SYNC REM Sync to the Screen
ENDWHILE REM End of Vertex Editor Loop
WHILE mode=1 REM Tile editor Loop
IF OBJECT VISIBLE(1)=1 THEN HIDE OBJECT 1
height=GET MATRIX HEIGHT (1,xpos,ypos) REM Get The Height of the Vertex Curently Selected
height1=GET MATRIX HEIGHT (1,xpos+1,ypos)
height2=GET MATRIX HEIGHT (1,xpos,ypos+1)
height3=GET MATRIX HEIGHT (1,xpos+1,ypos+1)
GOSUB keyboard_tile REM Go to the keyboard_tile bookmark
GOSUB check_values_tile REM Go to the check_values_tile bookmark
GOSUB mode_change
MAKE OBJECT TRIANGLE 2, xpos*xstep, height, ypos*ystep, xpos*xstep, height2,(ypos+1)*ystep,(xpos+1)*xstep,height3,(ypos+1)*ystep
MAKE OBJECT TRIANGLE 3, xpos*xstep, height, ypos*ystep, (xpos+1)*xstep, height3,(ypos+1)*ystep,(xpos+1)*xstep,height1,ypos*ystep
COLOR OBJECT 2,RGB(255,0,0)
COLOR OBJECT 3,RGB(255,0,0)
POSITION CAMERA xpos*xstep,height+100,ypos*ystep-100 REM Position the camera
POINT CAMERA xpos*xstep,height,ypos*ystep REM Point the camera at the vertex being edited
UPDATE MATRIX 1 REM Updates the Matrix or Terrain
SYNC REM Sync to the Screen
DELETE OBJECT 2
DELETE OBJECT 3
ENDWHILE REM End of Vertex Editor Loop
LOOP REM End of main loop
END REM End The Program
check_values_tile:
IF xpos<0 THEN xpos=0
IF xpos>79 THEN xpos=79
IF ypos<0 THEN ypos=0
IF ypos>59 THEN ypos=59
RETURN
check_values_vertex:
IF xpos<0 THEN xpos=0
IF xpos>80 THEN xpos=80
IF ypos<0 THEN ypos=0
IF ypos>60 THEN ypos=60
RETURN
keyboard_tile:
IF UPKEY()=1 AND last_up=0
INC ypos,1
last_up=1
ENDIF
IF UPKEY()=0 AND last_up=1 THEN last_up=0
IF DOWNKEY()=1 AND last_down=0
DEC ypos,1
last_down=1
ENDIF
IF DOWNKEY()=0 AND last_down=1 THEN last_down=0
IF RIGHTKEY()=1 AND last_right=0
INC xpos,1
last_right=1
ENDIF
IF RIGHTKEY()=0 AND last_right=1 THEN last_right=0
IF LEFTKEY()=1 AND last_left=0
DEC xpos,1
last_left=1
ENDIF
IF LEFTKEY()=0 AND last_left=1 THEN last_left=0
IF KEYSTATE(72)=1 AND last_num8=0
SET MATRIX HEIGHT 1,xpos,ypos,height+5
SET MATRIX HEIGHT 1,xpos+1,ypos,height1+5
SET MATRIX HEIGHT 1,xpos,ypos+1,height2+5
SET MATRIX HEIGHT 1,xpos+1,ypos+1,height3+5
last_num8=1
ENDIF
IF KEYSTATE(72)=0 AND last_num8=1 THEN last_num8=0
IF KEYSTATE(80)=1 AND last_num2=0
SET MATRIX HEIGHT 1,xpos,ypos,height-5
SET MATRIX HEIGHT 1,xpos+1,ypos,height1-5
SET MATRIX HEIGHT 1,xpos,ypos+1,height2-5
SET MATRIX HEIGHT 1,xpos+1,ypos+1,height3-5
last_num2=1
ENDIF
IF KEYSTATE(80)=0 AND last_num2=1 THEN last_num2=0
RETURN
keyboard_vertex:
IF UPKEY()=1 AND last_up=0
INC ypos,1
last_up=1
ENDIF
IF UPKEY()=0 AND last_up=1 THEN last_up=0
IF DOWNKEY()=1 AND last_down=0
DEC ypos,1
last_down=1
ENDIF
IF DOWNKEY()=0 AND last_down=1 THEN last_down=0
IF RIGHTKEY()=1 AND last_right=0
INC xpos,1
last_right=1
ENDIF
IF RIGHTKEY()=0 AND last_right=1 THEN last_right=0
IF LEFTKEY()=1 AND last_left=0
DEC xpos,1
last_left=1
ENDIF
IF LEFTKEY()=0 AND last_left=1 THEN last_left=0
IF KEYSTATE(72)=1 AND last_num8=0
SET MATRIX HEIGHT 1,xpos,ypos,height+5
last_num8=1
ENDIF
IF KEYSTATE(72)=0 AND last_num8=1 THEN last_num8=0
IF KEYSTATE(80)=1 AND last_num2=0
SET MATRIX HEIGHT 1,xpos,ypos,height-5
last_num2=1
ENDIF
IF KEYSTATE(80)=0 AND last_num2=1 THEN last_num2=0
RETURN
mode_change:
IF SPACEKEY()=1 AND last_space=0
IF mode=0 THEN mode=1
IF mode=1 THEN mode=0
last_space=1
ENDIF
IF SPACEKEY()=0 AND last_space=1 THEN last_space=0
RETURN
THANX IN ADVANCE
SOLVED this is my problem
IF mode=0 THEN mode=1
IF mode=1 THEN mode=0
even if mode was equal to 0 after its set to 1 its set to 0 again