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

as the title says. I have worked on my platform engine to be a little better and use less resources. I have made a level editor, and I removed the need for the player to collide with a zillion different processes.


it only uses 8mb of ram, can you see why its not working on the dreamcast? thanks
werg

handsource-dyko

Ahhh. It works nicely!  :) Very good job. You see, with a lot perservation and experimenting and patience you eventually reach your goal. ;)

MisterN

If I change the speed of the gravity it completely throws off the collision
werg

handsource-dyko

That's weird. But, this may heve someting to do with the loop counter conditions. I hanven't looked at the code, but I recall a problem I had years back of a moving logo that moved down the screen. When the logo reached a certain y-value, the loop had to stop. But it didn't work because I used == and a even number as condition and my counter added in different steps. So the counter overshoot it's mark and the condion was never met. So, maybe your problem is simlair.

MisterN

#4
Ok.

Now how do I spawn an enemy with structs?

enemy_a[0] = enemy_a();
enemy_a[0].x = x;
enemy_a[0].y = y;


does not work
werg

handsource-dyko

A processes (like from an enemy for example) is a struct by itself. You have to modify the process instance data.
So you create process instances in a for loop. It is similair to blocks.




handsource-dyko

#7
An array (list) that is used to store process id's. Note you can only change the processes' local and/or public data with this.


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


// code for putting processes on screen (a for loop is better if you have a lot of instances)
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);




Each process instance get's it's own id code when it's created, and we have stored them in the array for conveince.
This way, you can easily change the value's of a particulair enemy.

Let's change the x-value of enemy 7: my_procs[7].x=200;
This is similair to changing the values of a process  instance that causes a collision with another process instance. (Collision function
is based on id codes too, it's more or less the same).

In malvado I use a "hand cursor" in the editor. It simply uses the collision function, so I can affect the data of the object process instance I selected, but I also change the data structure. That's Why I stored the process id's in an array.

You can also inspect the data of instances with the debugger. Here's an example of the debugger in mampedit, showing th id code and the
data structure. http://dykodesigns.woelmuis.nl/bennu/malvado/dev-docs/entitytypes.html#mvs (Right click on the images to enlarge them).

You may also look at this http://code.google.com/p/malvado-bennuremake/wiki/ProcessIdentifiers] and http://code.google.com/p/malvado-bennuremake/wiki/Defines this as additional referencs.

MisterN

Can you take a look at this? The problem I am having is:
*if I place the objects and then press enter to load the level, everything is hidden behind what I just loaded.
*Same rule applies if I load the level first and then place objects
*The way things are, do you think itll work when loaded?

thanks
werg

handsource-dyko


MisterN

werg

handsource-dyko

I noticed that old blocks stay in place.I see that you use the put function to place the blocks. What I mean is, that when you load/render a new level, you must clear (reset, same as rendering, but now putting default data in) the data structure, and replace the blocks with empty ones. Basically you just put black or "empty" tiles over the old ones. If you use processes, you just kill them before you create new ones (for enemies etc).

MisterN

can you please throw it all together for me? im not doing processes for the level because that rapes the dreamcasts ram. my method only uses about 48% of the dreamcasts ram at all times.
werg

handsource-dyko

I described it in a more general way. Process killing only for enemies in your case. For the backgrounds, put black tiles in place before you place
the "loaded" tiles from the level file. Basically, you do the same thing twice (more or less).

MisterN

werg