Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
A simple Wall object question; Hopefully will be easy to answer?
Topic Started: Aug 19 2006, 06:02 PM (253 Views)
williac
Advanced Member
[ *  *  * ]
Im trying to load a level from a text file I have created with another program.

Posted Image
what I have is the x,y,x2, and y2, of each wall I want to place in the room.

example of text file (should make a square room)

Code:
 

number of panels :4
texture name,x1,y1,x2,y2,height
brickwall_red.jpg;304;192;432;192;10;
brickwall_red.jpg;432;192;432;304;10;
brickwall_red.jpg;432;304;304;304;10;
brickwall_red.jpg;304;304;304;192;10;


I am able to get GM to read the file, and using Blank wall objects(standard wall objects missing the creation event.) and then assign the proper x,y,x2,y2,ect to each previously created blank wall and run the CreateWall() function for each.
Code:
 

if file_exists('output.txt')
{
   map=file_text_open_read('output.txt')
   str=file_text_read_string(map)
   panel_total=real(string_digits(str))
   room_caption='panel_total :'+string(panel_total)
   while int<panel_total
   {
       panel[int]=-1
       int+=1
   }
   int=0
   file_text_readln(map)
   file_text_readln(map)// this skips to the first panel data line
   while not file_text_eof(map)
   {
       global.str=file_text_read_string(map)
       global.x=real(string_parse(global.str,1))
       global.y=real(string_parse(global.str,2))        

       global.x2=real(string_parse(global.str,3))
       global.y2=real(string_parse(global.str,4))
       


       panel[int]=instance_create(global.x,global.y,blankwall)
       with(panel[int])
           {
               setup=true
               x2=-(x-global.x2)//trying to make the x2 coor relative to x
               y2=-(y-global.y2)//trying to make the y2 coor relative to y
               dx2=global.x2// for use in the drawline() function
               dy2=global.y2//for use in the drawline() function
               height=10
               texture=1
               CreateWall()

           }
       int+=1
       file_text_readln(map)
   }



   file_text_close(map)
}
else
{
room_caption=' no map file to read!!!!!!!!!!!!!!!!!!!!'

}


I also have each Blank wall drawing a line (GM function) between its x,y and its x2,y2. when I switch to the game maker view and make things visible. I can see that the lines created by the drawline() function looks like the level I am trying to create.

Posted Image

but the wall drawn in the U3d aren't placed where I was expecting them to be.

Posted Image

Ive struggled with this for awhile now. Its probably something simple that I have overlooked.

Any help would be great thanks.

WILLIAC
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
May it be that the arguments for string_parse are wrong? I couldn't find this function in the GM help file but the second argument seems to be some kind of index and indices usually start with 0.
Offline Profile Quote Post Goto Top
 
williac
Advanced Member
[ *  *  * ]
string_parse is one of my own

Code:
 

//////////////////////////////////////////////////////////////////////

sep_number=string_count(';',argument0)
tint=0
mystring=argument0
while tint<sep_number
/// this sets up an array to hold all of the chunks from argument0
{
   chunk[tint]=''
   tint+=1
}
tint=0
while tint<sep_number
// this loads the chunk[x] array with data
{
   // the following finds the first chunk of mystring
   chunk[tint]=string_copy(mystring,1,string_pos(';',mystring)-1)
   
   // the following removes the first chunk of mystring
   mystring=string_delete(mystring,1,string_pos(';',mystring))
   tint+=1
}

return(chunk[argument1])



I use it pretty often.

if the string you where parsing is

Code:
 
stringname=one;two;apple;purple;


the function call of
Code:
 
string_parse(stringname,2)
would return apple
Code:
 
string_parse(stringname,1)
would return two
ect,ect

I am getting the proper coordinates when I read the text file. I can tell because when I have the wall objects draw a line between their x,y coordinates and their x2,y2 coordinates it is correct. Im really confused as to why the walls in the U3d view arent drawn the way their coordinates would indicate. Im setting the x,y,x2,y2,hieght,and texture variables. I am really stuck on this.

thanks for your quick response. I dont want to cut into your time since your developing U3d 2.0 and are most likely very busy. But if you have any Ideas let me know.

Thanks WILLIAC
Offline Profile Quote Post Goto Top
 
williac
Advanced Member
[ *  *  * ]
I solved this.

Instead of using U3D wall object to display the level I saved in a text file, I used U3D polygon objects.

Works great now.

U3D ROCKS!!!!!!!!!!!

WILLIAC
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply