Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1] 2   Go Down

Author Topic: Zelda GB Basic Engine  (Read 6214 times)

0 Members and 1 Guest are viewing this topic.

Ryuza

That one guy
Zelda GB Basic Engine
« on: February 17, 2010, 05:41:58 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
[ - ~ Legend of Zelda GB Style Engine ~ - ]

[-Description-]
Well, I started off with messing around with an old GB engine I had when I ran into a small problem on my other project and now I've decided to try and make a GB style engine, I'll be posting my progress as .gmk so everyone can check it out, I want to try and make the engine as easy to use as possible so if you see something that could be done in a simpler way or something that doesn't make sense and isn't needed please let me know.

[-Features-]

  • Basic Movement (Goodnight)
  • Swimming
  • Changing Tunics
  • Simple Effects (Grass & Splash)
  • Shield (just for show at the moment)

[-Currently Working On-]
Fixing the push block.

[-Known Issues-]
The 'obj_basic_push' is not able to be pushed, I didn't give the problem too much attention though so it's likely something simple.

[-Last Updates-]
2/20/2010: Added the shield and fixed the HUD a bit.

2/19/2010: Made a bigger room to prepare for later testing, added the effect for moving in a grassy area, and changed around the point that tracks water collision a bit. I also cleaned up a bit of the comments in the create event since I still had some from my old movement code. Added a basic item (flippers) used to test the item pickup, no comments in the code yet and its a bit messy at the moment but I'll be cleaning it up. Also added the HUD, mostly just to see how it would look, I need to fix the view since you can see it if you go to the bottom left corner.

2/18/2010: Added/Modified Goodnight's movement code, the movement is now almost exactly the same as in Ages and Seasons, and I matched Link's collision mask almost pixel for pixel with the one in Ages and Seasons. As far as I can tell Link collides with objects in nearly the exact same way in this engine as he does in the game. The only difference in movement is that he can 'slide' along walls while pushing, something I still need to figure out. Water is also fixed, in the step event for Link there is a var that tracks a single point that makes Link swim when that point collides with water. I also added the splash effect to going into water.

Decided to clean the post up a bit and make it look a bit more like a project.
« Last Edit: February 21, 2010, 04:47:50 am by RyuKage2007 »
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube
Re: Zelda GB Basic Engine
« Reply #1 on: February 17, 2010, 07:08:55 pm »
  • AKA "Micah DS"
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1347
First of all, WHY THE HECK IS IT SO FREAKIN LARGE!?!? It barely has anything in it. It makes no sense to be 4.7 MB.

Also, it doesn't recognize the variable "slowmove". So I turned on "treat uninitialized variables to 0", then I played again and found that the up and down are reversed...? Also, I got completely stuck.

I'm not trying to be mean, but.. did you test this out at all? I don't understand why there would be so many errors. :huh:

EDIT:
NM, it's just that up and down both move up. They aren't reversed.

EDITx2:
Also, if you hold down space and touch a direction, Link will move then stop, but his walking animation keeps going until space is released.

EDITx3 (I keep testing and finding new things, lol):
Ok, with the movement and getting stuck. It's one simple fix.
You simply missed switching "y -= 2" to "y += 2" on the down key event.
Code: Text
  1. if keyboard_check(vk_down) {dir = "D" image_speed = .4 if place_free(x, y + 1) {if slowmove = true {y += 1} else {y -= 2}}}
That fixes the getting stuck in the wall problem I mentioned earlier.

EDITx4:
Also if you hold two opposing directions (left and right or down and up), you will stay in one place with a walking animation still going. Must fix that.

Ok, I'm done testing it. I suggest that you test it yourself a tad bit more though and resubmit it. :P
« Last Edit: February 17, 2010, 07:26:51 pm by FrozenFire »
Logged
  • My Music

Ryuza

That one guy
Re: Zelda GB Basic Engine
« Reply #2 on: February 17, 2010, 07:49:53 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
Oops, that was my bad, I accidently uploaded a bit of an unstable version of it, I was trying out something and it got messed up. I'll see if I can fix it, also, I'm not sure why its 4.7mb, I couldn't figure it out myself, maybe I'll start a new file and move everything over and try and figure it out. I did test it before uploading I just got mixed up and didn't upload the one I tested. I'll repost a stable version of it in a minute.

Edit: Okay, fixed it, I think I accidently deleted the + for the down key event and replaced it with a - without thinking. Gonna Fixed the animating with the space bar, and for the opposite direction thing I was having a bit of trouble with it before but I think I thought of a way to fix it now.

Also, fixed the file size, I have now idea why it was so big before but I just exported everything and imported it into a new file and its fine now.
« Last Edit: February 17, 2010, 09:19:31 pm by RyuKage2007 »
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube
Re: Zelda GB Basic Engine
« Reply #3 on: February 17, 2010, 10:54:00 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
I'll take a look at it once I wake up again. Goodnight.
Logged
Re: Zelda GB Basic Engine
« Reply #4 on: February 18, 2010, 01:37:23 am »
  • AKA "Micah DS"
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1347
Ah, much better. I realized I did not say before that I like how you change the tunic color with very little sprites and code. Great job on that.

As far as the other coding goes, everything looks good to me except the movement still needs a tad bit of fixing up (the "opposing directions" fix). I looked at the code for a couple minutes but my brain is seriously fried today so I didn't figure out a good way to fix it. I'm sure you'll be able to though after a bit of thought. Or someone else should be able to help with that easily enough.
Logged
  • My Music

Ryuza

That one guy
Re: Zelda GB Basic Engine
« Reply #5 on: February 18, 2010, 01:54:10 am »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
Thanks for the compliment on the tunic code :). I kinda just copied in an old bit of movement code I had been using so that I could skip straight to working on the tunic, swimming, and pushing. I'm gonna go back and fix up the movement after I get out of class tonight though. Anyone have any tips on how to deal with opposing movement?
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube
Re: Zelda GB Basic Engine
« Reply #6 on: February 18, 2010, 08:50:23 am »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
I have taken a look at your engine for a quickie and found immediately an error. See the screenshot. I suggest you take a look at the collision mask.

I have to say that changing the colors of the tunic is really nicely done and would allow for many colors to be used in the game. But you still need 2 sprites for every frame of every animation. For a GB engine this really works well yes.

For basic movement, I suggest that you take a look at Goodnight's movement engine or the Community Project. I know those are made with MC graphics, but over all those years the movement behavior has not changed much or at all for 2D Zelda's. Thus the code for basic walking in MC should also work for GB.


EDIT: Setting the color is not really good. The value of global.color gets set every step, but it is dependent on the value of tunic. And tunic you change only at the press of the spacebar. I would merge both tunic and color into one variable. Making constants of the used color values. And thus only changing/setting the color when the space bar is pressed.
« Last Edit: February 18, 2010, 09:29:41 am by Niek »
Logged

Ryuza

That one guy
Re: Zelda GB Basic Engine
« Reply #7 on: February 18, 2010, 02:09:13 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
Yeah, I've been having a bit of problems with the water. I was hoping to get a smooth transition to and from the water with only two objects, if you hadn't noticed the water object places a water exit object in a border around it when created. I think I thought of a good way to fix that though. As for movement, yeah, I'll probably move on over to Goodnight's movement, I wasn't sure if it would match GB style at first, but if any part doesn't match I'm sure it wouldn't require much tweaking.

Thanks for checking it out though, you always seem to have good ideas when it comes to trimming down my code, that tip for the constants worked very well, I've never even used constants before now. I'll update the first post with the new version in a minute after I finish integrating Goodnight's movement into the game.

Edit:
Well, I updated the first post with a new version that has Goodnight's movement, the pushing blocks don't work right but I haven't really tried to fix them, at the moment I'm currently working on fixing the water.

Edit 2:
Modified Goodnight's movement a bit to match GB style, specifically the move speed, animation speed, depth and the time it takes for Link to start pushing an object.

Edit 3:
Couple new updates, check first post for info.

By the way, does anyone know how I might be able use the value of a variable as part of a resource name? For example if I wanted to do something like "spr_water_+string(global.waterdepth)" and then  if global.waterdepth = "deep" I'd end up with "spr_water_deep" or something.

Also, random screenshot.
« Last Edit: February 20, 2010, 04:55:20 am by RyuKage2007 »
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube

Ryuza

That one guy
Re: Zelda GB Basic Engine
« Reply #8 on: February 22, 2010, 07:49:24 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
Sorry about the double post, I figured it'd be fine to bump this after a couple days.

Anyway, I'm currently working on the inventory system/HUD. I've been running into a few problems with it, so anyone have any suggestions about how to track weapons owned and weapons in the inventory with arrays? I've never used arrays before. I've read up on the basics of arrays but I'm not quite sure where to start. Any ideas?
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube
Re: Zelda GB Basic Engine
« Reply #9 on: February 22, 2010, 09:26:33 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Well, there are a number of options, but as you want to make a GB inventory system, you need to make it dynamic. One option like you said can be done with arrays. This would require at least 2 arrays.

Starting with the weapons:

The first array is the inventory system, where the first 2 indexes are the A and B button position. The second array is the array with all the weapons that you have and what level it is, in case of multi level weapons like swords.

In the first array you store numbers, which represent an index of the second array. Thus in the first array no value of any position is the same as a value on another position, with the exception of the value -1, which represents an empty slot. (-1, because array indexes start with 0).

In the second array each position represents one of the weapons link can use. This is fixed, so it might be possible to make constants in order to give names to positions (but absolutely not necessary). Here you store what level of the weapon you've got. 0 means you don't have the weapon yet and 1 and higher is the level of the weapon. Although if you do not have the weapon yet the index won't be found in the first array.

When selecting weapons, you just swap the values of the two index positions. I don't think I have to explain how you swap values in arrays.

When drawing the inventory system you can loop through the first array to see what weapon needs to be drawn at the given position of the screen and the second array gives you what level it is. Now how the looping is done and drawing everything at the right position I suggest you take a look at the Community Project and the HUD part. Look specific for the part that draws the hearts. The same math can be applied here. With a switch statement you can see what icons to draw. Or you can use another array, where each index represents the weapon (like the second array) but that array stores scripts that execute various actions with the weapons, or the sprite indexes belonging to the weapon.

Now for the collectables you can put that in the same arrays, or a separate. I would do the latter, because those are things you have received like flippers or dungeon trophies. These have their own position on the screen thus are probably hardcoded and you only need to know if you've got them or not.

I hope this helps and I suggest you take a look at the CP.
Logged
Re: Zelda GB Basic Engine
« Reply #10 on: February 22, 2010, 09:30:24 pm »
  • *
  • Reputation: +12/-2
  • Offline Offline
  • Gender: Male
  • Posts: 4849
Not to come in and bag on you but dlbrooks has been doing this for a few years now.
If you want some pointers on GB style, you should check out his engines/games.
Here are some atleast that I found:
 http://www.zfgc.com/forum/index.php?topic=22429.0
http://www.zfgc.com/forum/index.php?topic=20391.0
http://www.zfgc.com/forum/index.php?topic=13348.0

If you actually read through the pages, he released the engines/gmks eventually.

Best of luck, though! ^_^
Logged
  • Super Fan Gamers!

Ryuza

That one guy
Re: Zelda GB Basic Engine
« Reply #11 on: February 23, 2010, 02:02:23 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
Thanks for all the info Niek, I managed to get a decent working inventory system going a bit before I saw your post but I think it's a bit messy. I've attached the inventory system by itself if you want to check it out. It runs pretty well but I think it could be trimmed down a bit more, any suggestions?

Thanks for the links Foreshadower, I saw that dlbrooks had been working on gb style but I never noticed those topics before.

Edit: I've attached the current executable for the engine, it now has the inventory system added, the code is still a bit messy though so I won't be adding the source till I clean things up a bit. The items in the inventory don't work and are mostly for testing but if you equip the shield then link's sprite will change.
« Last Edit: February 23, 2010, 04:10:11 pm by RyuKage2007 »
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube
Re: Zelda GB Basic Engine
« Reply #12 on: February 24, 2010, 06:05:53 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Hmm, I have taken a look at your inventory system. It looks alright, but I have a few remarks.

The first one is how are you going to execute weapon actions. If you don't know this, than it is a bit premature to make an inventory system. Just find out how you are going to deal with that until then I'll give some more C+C

Second, why are you using an separate object and sprite to make a fade effect. I would just draw a primitive shape with an increasing/decreasing alpha setting.


Oh yes, one more thing. You're coding conventions makes my spine shiver. For example:
Code: [Select]
if keyboard_check_pressed(ord('A')) {switch menu {case 0: scr_fade(c_white) menu = ringbox break; case ringbox: scr_fade(c_white) menu = 4 break; case 4: scr_fade(c_white) menu = 0 break;}}
« Last Edit: February 24, 2010, 06:47:49 pm by Niek »
Logged

Ryuza

That one guy
Re: Zelda GB Basic Engine
« Reply #13 on: February 24, 2010, 06:45:02 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
Thanks for taking the time to check it out Niek. For using weapons I've already got it figured out, I made a script for Z/X that has a switch statement that checks what is currently contained in that slot and uses the correct script for that weapon, it works pretty well so far but I do only have one weapon:
Code: [Select]
switch ctrl_menu.slot[16, 0] {
    case global.item[15, 1]: scr_weapon_bow() break;
    }

As for the fade object, at the time I made it I was thinking that the fade object would eventually be turned into an object that deals with all effects like fading, screen flash, etc. But yeah, probably would be a bit easier to just draw it up instead of having a sprite, and I could probably have the menu control effects too.

I'm just about done working the inventory system into the main engine, its in and working fine but I'm gonna be going through and cleaning some stuff up, I also have the second menu screen working, it draws up the tunic (matches whatever color you're wearing) and it draws the flippers when you have them.

Thanks again for the continued help.
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube
Re: Zelda GB Basic Engine
« Reply #14 on: February 24, 2010, 06:58:57 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
About the scripts is a good idea, but if you are using scripts then a switch statement is totally redundant. I suggest that you store the scripts to actions as well and then just use script_execute(variable_holding_script, arguments...)
Logged

Ryuza

That one guy
Re: Zelda GB Basic Engine
« Reply #15 on: February 24, 2010, 07:14:45 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
I think I get what you mean, I'll give it a try in a minute.

Also, I'm just about done with my source so I'll post in just a sec, just need to test a few things.

Edit: Well, its looking a bit better now. I severely reduced the amount of code used to draw Link, now there aren't eight different switch statements running at once to draw him :D. There may be a few variables left over that I was testing with, and I'm sure theres a couple bits of code that aren't needed but I'm still going through and cleaning it out. So let me know what you think.
« Last Edit: February 24, 2010, 07:22:24 pm by RyuKage2007 »
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube
Re: Zelda GB Basic Engine
« Reply #16 on: February 25, 2010, 02:41:18 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Okay, I have taken a quick look and haven't really found anything strange, besides that you can keep drowning if you don't have the flippers and continue to press in the direction of the water. You never see Link submerged. Not to mention that the submerged sprite is half in the water and half on the land. And when you come back you are standing on water.

I have also taken a look at your code. I can't really say  erstand it all, because it is really all over the place. And I have seen a lot of coding conventions, but yours is the first to bring shivers down my spine and to make my skin crawl. For example from your menu object step event:
Code: [Select]
var oldslot; // Used to track which item was in the Z or X slot before swapping with the slot the cursor resides at
oldslot = false;

if global.pause = true && alarm[0] = -1{ // Only activates the code when the game is paused.
    // Scrolls through equipment screens
    if keyboard_check_pressed(ord('A')) {sound_play(sfx_menu_open) switch menu {case 0: scr_fade(c_white) menu = global.keyitem[15, 3] break; case global.keyitem[15, 3]: scr_fade(c_white) menu = 4 break; case 4: scr_fade(c_white) menu = 0 break;}}

    if menu = 0 {
        // Assign an item to the Z slot
        if keyboard_check_pressed(ord('Z')) {
            sound_play(sfx_select)
            oldslot = slot[16, 0]
            slot[16, 0] = slot[cursor, 0]
            slot[cursor, 0] = oldslot
        }

        // Assign an item to the X slot
        if keyboard_check_pressed(ord('X')) {
            sound_play(sfx_select)
            oldslot = slot[17, 0]
            slot[17, 0] = slot[cursor, 0]
            slot[cursor, 0] = oldslot
        }
    }
    // Test different level ring boxes
    // Changing the ring level while on the key item screen will make it so you cannot change to the next screen until you're back at the original ring level.
    if keyboard_check_pressed(ord('R')) {if global.keyitem[15, 3] != 3 {global.keyitem[15, 3] += 1} else if global.keyitem[15, 3] = 3 {global.keyitem[15, 3] = 1}}

    // Move cursor around the screen and change the select variable accordingly
    if menu = 0 {
        // Moves the cursor up and if its at the top it will move down to the bottom.
        if keyboard_check_pressed(vk_up) {sound_play(sfx_cursor) if cursory != 8 {cursory -= 24 cursor -= 4} else if cursory = 8 {cursory = 80 cursor += 12}}
        // Moves the cursor down and if its at the bottom it will move up to the top.
        if keyboard_check_pressed(vk_down) {sound_play(sfx_cursor) if cursory != 80 {cursory += 24 cursor += 4} else if cursory = 80 {cursory = 8 cursor -= 12}}
        // Moves the cursor to the left and if its at the edge it will up one space and to the end of the previous row.
        if keyboard_check_pressed(vk_left) {sound_play(sfx_cursor) if cursorx != 22 {cursorx -= 32 cursor -= 1}
        else if cursorx = 22 { cursorx = 118
        if cursory != 8 {cursory -= 24 cursor -= 1} else if cursory = 8 {cursory = 80 cursor += 15}}}
        // Moves the cursor to the right and if its at the edge it will down one space and to the beginning of the next row.
        if keyboard_check_pressed(vk_right) {sound_play(sfx_cursor) if cursorx != 118 {cursorx += 32 cursor += 1}
        else if cursorx = 118 { cursorx = 22
        if cursory != 80 {cursory += 24 cursor += 1} else if cursory = 80 {cursory = 8 cursor -= 15}}}
    } //else if menu = 1 || menu = 2 || menu = 3 // <- use to set up the cursor for other parts of the menu
}
A part of it is decent, but other parts you put entire blocks of if/else and switch statements on a single line. I have a pretty wide screen with a 1920x1080 resolution, but some of these lines are even larger then my screen width. These conventions are really: Yyyaaarrrggghhh!!! I suggest if you want your engine to be readable for others and workable for others, that you change your conventions and unify them. Because this actually discourages me from working with your engine..
« Last Edit: February 25, 2010, 03:19:35 pm by Niek »
Logged

Ryuza

That one guy
Re: Zelda GB Basic Engine
« Reply #17 on: February 25, 2010, 03:15:12 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
Well my problem is that I keep changing my mind about how I want to layout my code, and then I forget to go back and change the rest of my code to match it <.<

I'll update this post in a minute with a much cleaner version. Also, I know what you talking about for the drowning thing, I think I have a quick solution that I can give a try, it should at least keep the sprite from being on the land.

Edit: Okay, now that I've looked at it a bit more, yeah, that was pretty bad... I cleaned it up though so it should be fine now. Hopefully it'll be a bit easier to work with now. Also, the idea I had to fix the water didn't work, I'll see if I can figure something out a bit later. I did change around some stuff to make the collisions a bit better for it so link doesn't walk across it when walk down onto it but he still drowns on land.
« Last Edit: February 25, 2010, 03:50:54 pm by RyuKage2007 »
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube
Re: Zelda GB Basic Engine
« Reply #18 on: February 26, 2010, 10:28:53 am »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Hmm, it seems your engine uses Pro features and I don't have pro features on my laptop. Thus I can't comment yet. But I think the collision point for drowning was correct, but you just need to move Link a bit more into the water and after it move Link back on the land. Don't keep Link at the point of collision.
Logged

Ryuza

That one guy
Re: Zelda GB Basic Engine
« Reply #19 on: February 26, 2010, 01:34:00 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
Ah, the pro features I'm using are just for the tunic blending right now, you could probably go into the draw event and turn the draw_sprite_ext line into a comment, it'll just make links tunic white. Anyway, I tried moving Link a bit more into the water for drowning but then he gets stuck if you hold the key towards the water so I need to fix that problem first. Let me know what you think when you get a chance to check it out on your desktop.
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube
Pages: [1] 2   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.031 seconds with 78 queries.