Prince 2 xna editor in Chsarp

Discussions about all other tools (CusPop, SAV/HOF editors) and hex editing.

Moderator: English Moderator Team

salvadorc17
Calif
Calif
Posts: 523
Joined: August 27th, 2011, 2:04 am

Prince 2 xna editor in Chsarp

Post by salvadorc17 » September 29th, 2014, 12:18 am

Hi, today im posting my firts attemps to prince 2 xna game editor, based from the pop net of Andrea Fallapi, aka "polipo", using the csharp i will try to create an editor for the basic structure level he made in xml.

The firts thing i need to understand and implement is about isometric draw of prince game.

Code: Select all

Each row has columns and each one has tiletypes: Level structure 3 rows x 10 colums.
<Column>
          <tileType>block</tileType>
        </Column>
Image

polipo
Vizier
Vizier
Posts: 89
Joined: September 6th, 2012, 8:34 am

Re: Prince 2 xna editor in Chsarp

Post by polipo » October 1st, 2014, 9:02 am

Dear,
the original PoP.net xml structure isn't good, i have maded it when i don't know exactly the
xml serialization and Prince game.
Why don't use the Apoplexy format ? in this format i don't like the "events" structure but the other is quite good.

But.. return to PoP.net structure...
Yes every room have
Number : 3 "Row" in "rows" list
Number : 10 "Column" in "columns" list

Column i can rename into "Tile" or "Block", this have all properties for
choose the tile, sprite, effects etc.

public Enumeration.TileType tileType = Enumeration.TileType.block;
public Enumeration.SpriteType spriteType;
public SpriteEffects spriteEffect;
public Enumeration.StateTile state = Enumeration.StateTile.normal;
public int switchButton = 0;
public Enumeration.Items item = Enumeration.Items.none;


In your picture i see space between "Column" you must use the HEIGHT=128 and WIDTH = 64 misure and not the
REALHEIGHT=148 and REALWIDTH=128 for drawing tiles.

Bye

salvadorc17
Calif
Calif
Posts: 523
Joined: August 27th, 2011, 2:04 am

Re: Prince 2 xna editor in Chsarp

Post by salvadorc17 » October 1st, 2014, 9:26 pm

In your picture i see space between "Column" you must use the HEIGHT=128 and WIDTH = 64 misure and not the
REALHEIGHT=148 and REALWIDTH=128 for drawing tiles.
What do you mean with realheight, i had scaled it, becuase the real size is bigger than screen of editor can handle, also im trying joining the tiles, using the isometric info you give about pop.net.

Another question i have is how to use the switch event???

polipo
Vizier
Vizier
Posts: 89
Joined: September 6th, 2012, 8:34 am

Re: Prince 2 xna editor in Chsarp

Post by polipo » October 2nd, 2014, 8:57 am

For join tiles you can't take the REAL TEXTURE dimension (148x128) but the fake (126x64) if you draw it in INVERSE order
from down-right to up-left you can draw the room (640x400) = 64*10tiles and 126*3row=378 + header (6px) and footer (16px) = 400 px (screen height)

Swith event, have an index every tiles (gate or pressplate) are joined for index.
For example : pressplate in room x have swith=10 and pressplate in room y have swith=10 and the gate have switch =10.
It means if you press the plate x or y you can open the gate with switch 10; Ps you can have more than 1 gate with same switch in this case the pressplate x or y open all gate with switch=10.
i had scaled it, becuase the real size is bigger..han screen of editor can handle
mhh you can provide a scrollviewer for scroll the entire level? or simple you can handle only one room for screen
Another solution is scale all by constant factor *0.x in this case you must scale all tile measure by *0.x.
For example scale by 0.5 the REAL TEXTURE dimension (74x64) but the fake (63x30)

salvadorc17
Calif
Calif
Posts: 523
Joined: August 27th, 2011, 2:04 am

Re: Prince 2 xna editor in Chsarp

Post by salvadorc17 » October 3rd, 2014, 2:05 am

Will try to draw it as you say from down-right to up-left you, right now im doing it left-up to down-right. Also i will modify the events to allow different actions like loose floor activation and enemie creation in room, if possible...

Currently im testing using gtk + sdl for porting the editor for linux and other...

realXCV
Sheikh
Sheikh
Posts: 26
Joined: November 4th, 2011, 12:04 am
Location: Right here
Contact:

Re: Prince 2 xna editor in Chsarp

Post by realXCV » October 3rd, 2014, 5:00 am

Even better: draw the tiles from bottom-left to top-right as well as back to front. That way, overlapping parts will appear correctly.

salvadorc17
Calif
Calif
Posts: 523
Joined: August 27th, 2011, 2:04 am

Re: Prince 2 xna editor in Chsarp

Post by salvadorc17 » October 3rd, 2014, 9:20 pm

realXCV wrote:Even better: draw the tiles from bottom-left to top-right as well as back to front. That way, overlapping parts will appear correctly.
The problem is that the code use the "for switch statement automation", and the integer must be in progressive order, that means, x 0,1,2 and not x 2,1,0... If you understand me, that is the way the chsarp run the code...

realXCV
Sheikh
Sheikh
Posts: 26
Joined: November 4th, 2011, 12:04 am
Location: Right here
Contact:

Re: Prince 2 xna editor in Chsarp

Post by realXCV » October 3rd, 2014, 10:20 pm

Can't you do something like this?

Code: Select all

for (int y=2;y>=0;y--)
{
    for (int x=0;x<10;x++)
    {
       //drawing code goes here.
    }
}

salvadorc17
Calif
Calif
Posts: 523
Joined: August 27th, 2011, 2:04 am

Re: Prince 2 xna editor in Chsarp

Post by salvadorc17 » October 3rd, 2014, 11:19 pm

I got the same result doing that, i think will neccesary doing some math.trucate or any other formula...

User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 3163
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: Prince 2 xna editor in Chsarp

Post by Norbert » October 4th, 2014, 12:49 am

realXCV wrote:Can't you do something like this?

Code: Select all

for (int y=2;y>=0;y--)
{
    for (int x=0;x<10;x++)
    {
       //drawing code goes here.
    }
}
Tiles must be drawn from left to right (for x) and from bottom to top (for y).
This means realXCV's code is correct for both y (2-0) and x (0-9).

salvadorc17
Calif
Calif
Posts: 523
Joined: August 27th, 2011, 2:04 am

Re: Prince 2 xna editor in Chsarp

Post by salvadorc17 » October 4th, 2014, 10:05 pm

Ok, see what im doing and get same result:

Code: Select all

		for (short y=2; y>=0; y--) {


			for (short x=10; x>=0; x--) {


			    srect = new Sdl.SDL_Rect (0, 0, 64, 74);

				drect = new Sdl.SDL_Rect ((short)(x * 64),(short)(y * 74), 64, 74);

				Sdl.SDL_BlitSurface (imagen, ref srect, loc, ref drect);
			}



		}

salvadorc17
Calif
Calif
Posts: 523
Joined: August 27th, 2011, 2:04 am

Re: Prince 2 xna editor in Chsarp

Post by salvadorc17 » October 4th, 2014, 11:32 pm

Got it working in different way, firts, i used the tiles scaled to 64*74, second i decrease for each tile pos x-26, y-18. And i got it like this:

Image

realXCV
Sheikh
Sheikh
Posts: 26
Joined: November 4th, 2011, 12:04 am
Location: Right here
Contact:

Re: Prince 2 xna editor in Chsarp

Post by realXCV » October 5th, 2014, 1:25 am

That's better. But there shouldn't be any gap between the tiles. And there should only be 10 tiles on each line.

salvadorc17
Calif
Calif
Posts: 523
Joined: August 27th, 2011, 2:04 am

Re: Prince 2 xna editor in Chsarp

Post by salvadorc17 » October 7th, 2014, 2:45 am

What do you mean gap?? im exceding tiles number to 12, that can be easily fixed, but now i need to work on the layers, that will allow for draw sprites from prince, guards and items above the tiles, in the correct position...

realXCV
Sheikh
Sheikh
Posts: 26
Joined: November 4th, 2011, 12:04 am
Location: Right here
Contact:

Re: Prince 2 xna editor in Chsarp

Post by realXCV » October 7th, 2014, 5:15 am

They should be even more close to each others than this. The tiles you're using include the right part of them. That means that you have to make top parts touch each others. With the unscaled pictures, that could be achieved by drawing the tiles every 51 pixels. I don't know what the spacing is with your scaled pictures (should be equal to the width of one column) but if you draw them that way, they should appear correctly.

Post Reply