How to change dimensions of an enemy?

ModKeen mods Tiles and Sprites in all episodes of Commander Keen.
Post Reply
User avatar
Alopex
Posts: 25
Joined: Thu Jun 15, 2017 7:27 pm
Location: Bloogfoods, Inc.

How to change dimensions of an enemy?

Post by Alopex » Tue Jun 20, 2017 10:22 pm

Let me clarify: I want to modify the image 4SPR0333 of my Keen 4 mod (the "smaller" version of the Wormouth, when it walks hiding itself) with a replacement that have bigger dimensions than the original sprite.

Image

How can I do that?

User avatar
Fleexy
Site Admin
Posts: 472
Joined: Fri Dec 12, 2008 1:33 am
Location: Blogham Tower
Contact:

Re: How to change dimensions of an enemy?

Post by Fleexy » Tue Jun 20, 2017 10:48 pm

You can change the height of the bitmap to whatever you like. The width of the sprite must be a multiple of 8 because of how the EGA format works, therefore the bitmap's width must be a multiple of 24. The first third is the image, the center is the mask, and the right third is the clipping rectangle.

This is where things get tricky. The ?SPRITES.TXT file (4SPRITES.TXT for Keen 4) keeps some information about each sprite. The number before the colon is the sprite ID. The set of 4 numbers is the hitbox's size/location: left, top, right, bottom. I'm not sure whether this takes precedence over the gray-and-red box in the bitmap; a more experienced ModKeen user will have to answer that. The set of two numbers is the offset: X and Y. This is necessary to keep the sprite in the same position when it changes size throughout its behavior. The Keen shooting frames, for instance, have an offset so that Keen's body stays in the same place even though his image gets wider. Similarly, things that change height throughout their life will need to have their Y offsets engineered so they don't glitch up and down. The Y part is also important to make sure the bottom of the hitbox aligns with the ground when the sprite spawns. Finally, the last number is how smooth the sprite needs to move; it can be 1, 2, or 4. Higher values make for smoother movement, but also require more memory.

All this can take some trial-and-error.

User avatar
Nisaba
Posts: 267
Joined: Fri Jan 01, 2016 11:15 pm
Location: patch.pat
Contact:

Re: How to change dimensions of an enemy?

Post by Nisaba » Wed Jun 21, 2017 6:04 am

like Fleexy mentioned it before, it's really a matter of trail-n-error. for a deeper understanding of how things work, please make sure too read the following section of the tutorial with care:
http://www.shikadi.net/keenwiki/Keen_Ga ... )#Hitboxes

User avatar
Alopex
Posts: 25
Joined: Thu Jun 15, 2017 7:27 pm
Location: Bloogfoods, Inc.

Re: How to change dimensions of an enemy?

Post by Alopex » Wed Jun 21, 2017 10:41 am

OK, this thing is just funny:

I took a copy of sprite 4SPR0316 (the Underwater Mine in Keen 4)

Image


and I put it in BMP folder with the bitmap name 4SPR0333 (the "small" Wormouth),

Image

in order to replace the sprite of the Wormouth with the Underwater Mine. I also changed the appropriate line in the 4SPRITES.TXT of the Wormouth with the hitboxes attributes of the Underwater Mine. This is happening now: in some levels, the Underwater Mine (replacement of the "smaller" version of the Wormouth, when it walks hiding itself) works just fine, but in most levels it is stuck and literally sunk into the ground without moving.

Image

Image

Image


Why the new Wormouth sprite sometimes works properly and sometims not?

Do you have any tips?

User avatar
Nisaba
Posts: 267
Joined: Fri Jan 01, 2016 11:15 pm
Location: patch.pat
Contact:

Re: How to change dimensions of an enemy?

Post by Nisaba » Wed Jun 21, 2017 5:34 pm

ok, the hitboxes (ingame) of the Wormouth look something like this:

Image

depending on which sprite you have replaced, you want to make sure, to change the Y-coordinate of the second set of brackets (in your 4sprites.txt file). this value determines how far up or down the sprite is placed. so as your modded enemy is stuck in the ground (or in the air), you'll want to edit the Y value to bring the hitbox even with the ground.

if you could, please do also post your altered set of coordinates (plus the original values).

User avatar
Alopex
Posts: 25
Joined: Thu Jun 15, 2017 7:27 pm
Location: Bloogfoods, Inc.

Re: How to change dimensions of an enemy?

Post by Alopex » Sat Jun 24, 2017 9:54 am

Nisaba wrote:
Wed Jun 21, 2017 5:34 pm
ok, the hitboxes (ingame) of the Wormouth look something like this:

Image

depending on which sprite you have replaced, you want to make sure, to change the Y-coordinate of the second set of brackets (in your 4sprites.txt file). this value determines how far up or down the sprite is placed. so as your modded enemy is stuck in the ground (or in the air), you'll want to edit the Y value to bring the hitbox even with the ground.

if you could, please do also post your altered set of coordinates (plus the original values).
The original values of the Wormouth (the hidden version) are: 333: [0, -3, 7, 4], [0, 3], 4.

Image

I replaced these coordinates with the Underwater Mine ones: 316: [3, 3, 20, 20], [0, 0], 4.

Image

I'd like to create a Keen's enemy bigger than it, but with the same behaviour.

Post Reply