Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / loading and positioning level data

Author
Message
boonsy
14
Years of Service
User Offline
Joined: 8th Aug 2010
Location:
Posted: 8th Aug 2010 13:22
hi, we need to make a 3d, fixed camera platform game for school and im having a trouble loading the level size and position files into an array and then positioning them. the screen is just black. any help would be apprecciated. cheers [`screen setup
sync on
sync rate 60

`load and set main char
LOAD OBJECT "I:\school\trimester 2\DEV102\assessments\final game\man.x", 1
SCALE OBJECT 1, 50, 50, 50,
ROTATE OBJECT 1, 0, -90, 0

`variable for level objects
obj AS INTEGER = 2

`type for object screen placement
TYPE VECT2
x AS FLOAT
y AS FLOAT
z AS FLOAT
ENDTYPE

`player position variable
manPos AS VECT2
manPos.x = 50
manPos.y = 50
manPos.z = 0

`-----------------------level loading--------------------------------------------
`arrays for level data
DIM LevObjSize() AS LEVEL
DIM LevObjPos() AS LEVEL

TYPE LEVEL
LevPos AS VECT2
LevSize AS Vect2
active AS BOOLEAN
ENDTYPE


fileLine AS STRING
lineLen AS INTEGER
lineMid AS INTEGER

` Open the Level pos file
OPEN TO READ 1 , "I:\school\trimester 2\DEV102\assessments\final game\levelpos.txt"

` Read until the end of the file
WHILE FILE END(1) = 0
` Read the next line of data
READ STRING 1 , fileLine

` Insert a blank element in the LevObjPos list
ARRAY INSERT AT BOTTOM LevObjPos()

` Helper Data
` The length of the line
lineLen = LEN( fileLine )
` The middle of the line
lineMid = FIND FIRST CHAR$( fileLine , "," )

` make the x and y position of the block equal to the values either side of the comma
LevObjPos().LevPos.x = VAL( LEFT$( fileLine , lineMid - 1 ))
LevObjPos().LevPos.y = VAL( RIGHT$( fileLine , lineLen - lineMid ))
LevObjPos().LevPos.z = 16
ENDWHILE

CLOSE FILE 1

` Open the Level size file
OPEN TO READ 2 , "I:\school\trimester 2\DEV102\assessments\final game\levelsize.txt"

` Read until the end of the file
WHILE FILE END(2) = 0
` Read the next line of data
READ STRING 1 , fileLine

` Insert a blank element in the levObjSize list
ARRAY INSERT AT BOTTOM LevObjSize()

` Helper Data
` The length of the line
lineLen = LEN( fileLine )
` The middle of the line
lineMid = FIND FIRST CHAR$( fileLine , "," )

` make the x and y size of the block equal to the values either side of the comma
LevObjSize().LevSize.x = VAL( LEFT$( fileLine , lineMid - 1 ))
LevObjSize().LevSize.y = VAL( RIGHT$( fileLine , lineLen - lineMid ))
LevObjSize().LevSize.z = 100
ENDWHILE

CLOSE FILE 2

ARRAY INDEX TO TOP LevObjSize()
WHILE ARRAY INDEX VALID( LevObjSize() )
MAKE OBJECT BOX obj, LevObjSize().LevSize.x, LevObjSize().LevSize.y, LevObjSize().LevSize.z
INC obj, 1
NEXT ARRAY INDEX LevObjSize()
ENDWHILE

`reset obj value to 2
obj = 2
`position level objects
ARRAY INDEX TO TOP LevObjPos()
WHILE ARRAY INDEX VALID( LevObjPos() )
POSITION OBJECT obj, LevObjPos().LevPos.x, LevObjPos().LevPos.y, LevObjPos().LevPos.z
INC obj, 1
NEXT ARRAY INDEX LevObjPos()
ENDWHILE

`--------------------------------------MAIN LOOP -------------------------------------------
DO
`player controls
IF UPKEY() = 1

ENDIF
IF RIGHTKEY() = 1
manPos.x = manPos.x + 2
ENDIF
IF LEFTKEY() = 1
manPos.x = manPos.x- 2
ENDIF

`character position and camera
POSITION OBJECT 1, manPos.x, manPos.y, manPos.z
POSITION CAMERA 0, manPos.x+50, manPos.y+100 , manPos.z - 500
POINT CAMERA manPos.x+50, manPos.y+50, manPos.z

sync
LOOP]
luskos
17
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 9th Aug 2010 11:38 Edited at: 9th Aug 2010 13:01
First of all you can use CODE button so your code don't make people scroll the page few miles just to see where is the end of your post...

That's more an advice, just anybody here is gonna give it to you sooner or later.I wanted to be clear so you don't think i'm picking with you or something.Actually this is very nice function of our forum, if not best of all.

My question is how you managed to make your levels?You obiously allready have some information in these txt files loaded in your code.Did you do them all by hand.Typing?

Ask that because i myself begun terrainless world editor some time ago, but never finished it.I lack of 3d skills to do the objects i needed, because mostly i have time just barely for coding and nothing else.It's frozen in some tesing phase but it's functional.It can be converted with ease from terrainless to terrained world editor.

Any experiments i made with positioning of cubes, rotating and texturing, saving then loading the so called "level" have success.

I learned a lot in the process of making this "editor".And i'm gonna share the code here so it can be developed further or used as sandbox or even for base to start from in making your own editor.

I must say that controls are a bit twisted, but i made it so i used to it very fast.

I'm gonna search where i put it then i'm gonna make separate thread and give you link to it here.

I think this may speed up your game development.I doubt to be credited for this because you mentioned that the game is for some school...something...


EDIT: The link i talked about before:

http://forum.thegamecreators.com/?m=forum_view&t=173880&b=1

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Frank C
14
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Houston TX
Posted: 9th Aug 2010 16:29 Edited at: 9th Aug 2010 16:32
I think he did use the code button but didn't realize how to use it since he replaced the word 'Code' with his code.

To use the code button when you press it you get 'code' statement in brackets, you then paste your code after that statement. At the end of your code you click code button again to get the 'code close' statement.
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 9th Aug 2010 21:30 Edited at: 9th Aug 2010 21:31
*edit*

sorry bad post, mod please delete if you can

I can see from your smile, you're not here for the sunset

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD
mikewhl
14
Years of Service
User Offline
Joined: 19th Jul 2010
Location: Columbus,Ohio
Posted: 10th Aug 2010 22:17
Look at his join date.

I think we can cut him a little slac.

Mike

some cool stuff someone else said here

Login to post a reply

Server time is: 2024-11-23 10:55:42
Your offset time is: 2024-11-23 10:55:42