Perfect Player Collision w/ level editor

Started by MisterN, February 12, 2012, 03:02:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MisterN

This really makes absolutely no help at all unless I have some physical code to study from like I did the level editor (I got peices of that from the tiled example on fenixonfire). I switched back to the level editor published in this thread.
werg

handsource-dyko

What I mean is that you should modify your editor/engine with the stuff I told you. It is not that hard really. Just be creative. ;D

MisterN

Yes but im just confused. I just see words. I have tried and tried and tried and tried to get a struct variable to load a process, it will not happen.

level.pellet_obj[0] = pellet();
level.pellet_obj[0].x = x;
level.pellet_obj[0].y = y;

will save, but it will not load, please understand. I can advance so much if someone shows my why this isnt working and what I can do to make it work without a million lines of code. please
werg

handsource-dyko

The reason that is saves but not loads is because you'll assign the data from the pellet process into the struct member. In code you show you'll basically assign the default value's of the process to level_pellet_obj[0]. This will not work, you'll need the process instance, wich is different thing than a process type. In your code it's a process type. Sure it save's something, it's the default data! ??? :'( When it comes to loading, you'll go through a for loop that creates the instances. A couple of posts earlier I told something about using an array for storing process identifiers. Whenever a new instance is created, that instance get's it's own id code and data. So when you want to save the data, you'll need
to go through all instances and copy their data in each successive struct member. Hence, that's why you should store porcess id's in an array, so that with one for loop, you can copy the data of each instance.

You know, this code:


// array with process id's
int my_procs[9];

// the process instances have been created with these datas
my_procs[0]=enemy(100,100);
my_procs[1]=enemy(100,200);
my_procs[2]=enemy(100,300);
my_procs[3]=enemy(100,400);
my_procs[4]=enemy(100,500);
my_procs[5]=enemy(100,600);
my_procs[6]=enemy(100,700);
my_procs[7]=enemy(100,800);
my_procs[8]=enemy(100,900);
my_procs[9]=enemy(100,1000);

// code for saving 10 instances
For (i=0; <9; i+=1)

   level.pellet_obj.x[i]=my_procs[i].x;
   level.pellet_obj.y[i]=my_procs[i].y;
End

save ("level.dat",level);


// now load from file (creates 10 process instances)
load ("level.dat",level);

For (i=0; <9; i+=1)
   my_procs[i]=enemy(level.pellet_obj.x[i],level.pellet_obj.y[i]);
End

// after this loop you'll have 10 enemy processes loaded from a file.


I hope this finally answers your question. :'( ::)

MisterN

so that means there has to be a total of 10, no more no less of that object when loaded?
werg

handsource-dyko

Well, the number is what you want it to be. Depends on what you think that fits in memory. If your struct can hold 100 items, you dont't have put all of them on screen. That's why I always add a "used" variable, wich is either true or false. So when the file is loaded, the for loop does an extra check, if the value is true, it creates the process instance, if it's false, it skips it. In the malvado editor, when you add an item or delete one, this flag is set. That's all really. (It uses an algorithm that looks for such an empty slot when you insert an item, and if there isn't any, it will give an error message saying that the struct is full). Just try to put more then 50 bears in a level, that's the limit. But if there's at least one empty slot in the struct (becasue it's marked false) it add's an item. I created it this way because I didn't want to do a linked list because pointers give me a headache.

MisterN

werg

handsource-dyko

Isn't there an example in bennupack? I've looked at the 3 advandce\rpg_engine tutorial and a few others that have an editor.
My bennupack version is old, maybe newer versions have more examples. But I think you should be able to do it, I know that the wiki is lacking, but bennupack is full of examples.

MisterN

#23
its hard to rewrite the whole engine though. Cant you just spend that 10 minutes figuring out how the code will work? Im not gonna lie, the amount of time arguing, it could have been solved then and there and id be far more into my code for I will not continue until this is done, and if it exists, ive looked at it, doesnt help me.
werg

handsource-dyko

Well, that's the thing. It's not a mater of looking 10 minutes at it. Something like requires more time to do it right, and I don't have the time for it.

I have to admid, it took me years, with a lot of failed attemts, but that's something you'll learn from. Projects like this are more than just coding,  you need to consider your design and that requires a certain level of familairity with the language and programming concepts. I don't want to discourage you, but you have to experiment and accept that not all attempts are imidiately successfull the first time. Projects like this are long term things, you'll have to let it rest for some time, then get some ideas, mess with it, let rest again, do some other (smaller, more manageble) projects, get some more ideas, and eventually you'll reach to a point where everything becomes clear and fits together. ;)

I suggest you put it on a low pace, and just read some books about programming. I do this a lot, I found out that a lot of the stuff and concepts I read in C and pascal books is very usefull for bennu as well.

MisterN

Oh my god this is like the time I spent at a c++ forum

ive wasted 6 months and I cant delay the deadline any further. Im good at game mechanics, im not good at structures (actually I am good at structures, but howcome structures dont load processes when theyre loaded?).
werg

SplinterGU

I don't understand if you have a problem with your code or what...

If you have a problem, try ask in spanish.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

MisterN

werg

SplinterGU

sorry, is very hard understand you, for me...
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

gecko

i think that the way you're looking for help it's the problem.

We're here to help, of course, but you want and insist on on us to do the job that is yours.

Ask for ways of doing things, or ways to fix things, or ways to solve problems, but do not expect us to DO YOUR GAME. You can only learn by doing it yourself.

(and sorry for my english)
Torres Baldi Studio
http://torresbaldi.com