Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1387142 Posts in 66521 Topics- by 59075 Members - Latest Member: Ahren

January 21, 2021, 03:17:01 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsMy anniversary game
Pages: [1] 2
Print
Author Topic: My anniversary game  (Read 7385 times)
Randy
Level 0
***



View Profile WWW
« on: June 11, 2009, 09:55:51 AM »

Hello tigsource community.

I'm looking for a little help and feed back on my game project, but before I tell you want it is... let me give you some background on it.

See, for the past 4 years now, I've been making my wife an animated pixel gif for an anniversary card.  See...





So this year I'm looking to do something a bit different and make her a little game to play.  Nothing complex as she's not a gamer.  Just a simple, top down game where she can walk a little me around an island and do some "push block" puzzles.  Oh, she'll collect hearts too as she plays.  Collect all the hearts to rescue her at the end.  Here's a screen shot of what I have so far.



Here's what I have so far.  I can walk my character around in four direction and collect hearts.  What I haven't been able to do (or have yet to try) is push blocks, add a counter for the amount of hearts she's collected and change rooms so I don't have one HUGE room.  You can see what I have so here here.

CURRENT VERSION!
able to...

walk around
push objects
collect hearts
have a global hearts counter
change rooms (broken)


On top of this being my first game ever, I'm using Game Maker 6.  I'm slowly learning the GML and I've looked at a TON of examples and tutorials.  If anyone can help be out and/or give suggestions that would be great.

Thank you ^_^
« Last Edit: June 29, 2009, 09:14:13 AM by Randy » Logged
Zest
Level 10
*****


View Profile WWW
« Reply #1 on: June 11, 2009, 10:02:50 AM »

Those are so adorable! I can't really offer much help, but good luck with the project- hope she loves it.
Logged
Angelo
Level 1
*


Gah! My very funny personal text is too long for t


View Profile WWW
« Reply #2 on: June 11, 2009, 10:03:14 AM »

Wow. I want to play Sim Us!
Logged

MaloEspada
Guest
« Reply #3 on: June 11, 2009, 02:22:59 PM »

About the counter, I think I've got a easy way for you.
Make a global variable that holds the amount of hearts she has collected; each time the player touchs a heart, you add 1 to this global variable and make the heart disappear.

With a HUD object, you can draw the number that the global variable holds, so she can keep track of how many hearts she has collected.


Amazing pixel art, btw.
Logged
Chris Z
Level 7
**



View Profile WWW
« Reply #4 on: June 11, 2009, 02:26:16 PM »

Very nice idea, I think you motivated me to do something like this for my wife.  Our anniversary is in a month so I need to get crackin!  Coffee

I wish I could help, but I dont know anything about Game Maker.  Good luck!
Logged

JoeInky
Level 0
***



View Profile WWW
« Reply #5 on: June 11, 2009, 02:35:51 PM »

Hmm, I'm really good with gamemaker, and what youve said so far is actually really easy to do, you can add me on msn ([email protected])<add a . before com, and ill talk you through it if you want.
Logged
Randy
Level 0
***



View Profile WWW
« Reply #6 on: June 12, 2009, 05:16:37 AM »

Hmm, I'm really good with gamemaker, and what youve said so far is actually really easy to do, you can add me on msn ([email protected])<add a . before com, and ill talk you through it if you want.

Sure, I can add you but the only time I get to work on it is during my lunch time.  I'm on  MSN all day though.  So if you can't get on MSN until the evening, I'll never be able to talk to you.  I don't mind talking through this tread though.  That way everyone learns something. ^_^

Thank you very much as well by the way.
Logged
Randy
Level 0
***



View Profile WWW
« Reply #7 on: June 12, 2009, 05:19:19 AM »

About the counter, I think I've got a easy way for you.
Make a global variable that holds the amount of hearts she has collected; each time the player touchs a heart, you add 1 to this global variable and make the heart disappear.

With a HUD object, you can draw the number that the global variable holds, so she can keep track of how many hearts she has collected.


Amazing pixel art, btw.

Awesome, I'm going to try that next!  Hopefully I can figure it out.  I'll come back if I need help.

Also, your profile pixel girl is adorable. ^_^
Logged
ChevyRay
Guest
« Reply #8 on: June 12, 2009, 06:10:49 AM »

Pushing blocks completely depends on how you've set up your movement code. If your setup is something like this...

Normal movement:

Code:
movex = 0;
movey = 0;

// GET THE MOVEMENT OFFSET

if (keyboard_check(vk_right)) movex += 1;
if (keyboard_check(vk_left))  movex -= 1;
if (keyboard_check(vk_down))  movey += 1;
if (keyboard_check(vk_up))    movey -= 1;

// MOVE HORIZONTALLY

if (!place_meeting(x + movex, y, obj_solid)) x += movex;

// MOVE VERTICALLY

if (!place_meeting(x, y + movey, obj_solid)) y += movey;

Then you could effectively move blocks with this edit:

Block-pushing movement:

Code:
var movex, movey;
movex = 0;
movey = 0;

// GET THE MOVEMENT OFFSET

if (keyboard_check(vk_right)) movex += 1;
if (keyboard_check(vk_left))  movex -= 1;
if (keyboard_check(vk_down))  movey += 1;
if (keyboard_check(vk_up))    movey -= 1;

// PUSH HORIZONTALLY

pushh = instance_place(x + movex, y, obj_push);
if (pushh)
    with(pushh) if (!place_meeting(x + movex, y, obj_solid)) x += movex;

// PUSH VERTICALLY

pushv = instance_place(x, y + movey, obj_push);
if (pushv)
    with(pushv) if (!place_meeting(x, y + movey, obj_solid)) y += movey;

// MOVE HORIZONTALLY

if (!place_meeting(x + movex, y, obj_solid)) x += movex;

// MOVE VERTICALLY

if (!place_meeting(x, y + movey, obj_solid)) y += movey;

I actually don't know if that will work, I just wrote that off the top of my head. If you have an accelerating velocity, or even just a walking speed greater-than 1 pixel per-step, then there are a few changes you'd want to make to even that.




Alright, I just downloaded Game Maker 6 and tested that code out, and it works fine. Here's the .GM6 file if you want.

http://properundead.com/examples/push_example.zip

I made the system very rudimentary, for simplicity's sake. For example, your character cannot push more than one blocks with this, and cannot move dynamically (as I explained above). If you want any of these additional things added, or just need help adapting this code into your game Smiley just let me know and I'll help you out.

 Wizard
Logged
ChevyRay
Guest
« Reply #9 on: June 12, 2009, 06:19:40 AM »

I just made a 2nd example, which is a bit more complicated. This example shows how to allow your character to push several blocks using a recursive check.

http://properundead.com/examples/push_example2.zip
Logged
JoeInky
Level 0
***



View Profile WWW
« Reply #10 on: June 12, 2009, 06:51:57 AM »

Yeah, I see what you mean but I'm not very good at posting on forums, least of all talking about code.

But if chevy ray's knowledge hasnt helped you enough dont hesitate to add me.
I'm always on msn, at least 16 hours a day, seen as I'm pretty much continuosly working on Quest of a Mang.
Logged
MrChocolateBear
Level 1
*



View Profile WWW
« Reply #11 on: June 12, 2009, 11:32:17 AM »

Randy, best of luck on your project. I know she'll love it!
Logged

Randy
Level 0
***



View Profile WWW
« Reply #12 on: June 15, 2009, 09:27:00 AM »

Pushing blocks completely depends on how you've set up your movement code. If your setup is something like this...

Normal movement:

Code:
movex = 0;
movey = 0;

// GET THE MOVEMENT OFFSET

if (keyboard_check(vk_right)) movex += 1;
if (keyboard_check(vk_left))  movex -= 1;
if (keyboard_check(vk_down))  movey += 1;
if (keyboard_check(vk_up))    movey -= 1;

// MOVE HORIZONTALLY

if (!place_meeting(x + movex, y, obj_solid)) x += movex;

// MOVE VERTICALLY

if (!place_meeting(x, y + movey, obj_solid)) y += movey;

Then you could effectively move blocks with this edit:

Block-pushing movement:

Code:
var movex, movey;
movex = 0;
movey = 0;

// GET THE MOVEMENT OFFSET

if (keyboard_check(vk_right)) movex += 1;
if (keyboard_check(vk_left))  movex -= 1;
if (keyboard_check(vk_down))  movey += 1;
if (keyboard_check(vk_up))    movey -= 1;

// PUSH HORIZONTALLY

pushh = instance_place(x + movex, y, obj_push);
if (pushh)
    with(pushh) if (!place_meeting(x + movex, y, obj_solid)) x += movex;

// PUSH VERTICALLY

pushv = instance_place(x, y + movey, obj_push);
if (pushv)
    with(pushv) if (!place_meeting(x, y + movey, obj_solid)) y += movey;

// MOVE HORIZONTALLY

if (!place_meeting(x + movex, y, obj_solid)) x += movex;

// MOVE VERTICALLY

if (!place_meeting(x, y + movey, obj_solid)) y += movey;

I actually don't know if that will work, I just wrote that off the top of my head. If you have an accelerating velocity, or even just a walking speed greater-than 1 pixel per-step, then there are a few changes you'd want to make to even that.




Alright, I just downloaded Game Maker 6 and tested that code out, and it works fine. Here's the .GM6 file if you want.

http://properundead.com/examples/push_example.zip

I made the system very rudimentary, for simplicity's sake. For example, your character cannot push more than one blocks with this, and cannot move dynamically (as I explained above). If you want any of these additional things added, or just need help adapting this code into your game Smiley just let me know and I'll help you out.

 Wizard

Woah!  That's fantastic!  Thank you very much!

I've had to try and mess with the code a little so I can use it for my animations and I've run in to some problems.  I can push my rock object but it won't stop at the solid collusion tiles I've made.  Also, I need my sprite to face the direction he's been walking in when you've stopped pressing the walk button.  Now, I've actually got that to work but the problem is if I'm holding down left, for example, if I press up (or any other direction) my sprite will flash one frame in that direction as I walk.  Am I missing or forgetting something?

After these get sorted out I'm going to move on to the collecting hearts part.

OH!  I forgot, how do I get it so I can push my blocks/rocks on a grid?  That way I won't have rocks all over the stupid place when I push them?

He's a recent version of my progress.
Logged
Randy
Level 0
***



View Profile WWW
« Reply #13 on: June 18, 2009, 09:18:06 AM »

Okay, so I'm having problems with the depth of my objects at this point.  Everything starts out okay, but once I start pushing things around objects start to jump from one depth to another.  I have a screen shot to show what I mean.  Sad



I've added a counter for my hearts but have yet to figure out how to make it so I walk and/or push on a grid rather then per pixel movement.

Thank everyone for the help so far ^_^
Logged
JamesGecko
Level 3
***



View Profile WWW
« Reply #14 on: June 19, 2009, 12:54:05 AM »

It's been a while since I used Game Maker, but I'm pretty sure that you can set the z-depth manually.

You might try doing something like depth = self.y; every time a block is moved. I don't remember if lower depths are in front or higher depths, you may need to experiment on that.
Logged
ChevyRay
Guest
« Reply #15 on: June 20, 2009, 04:45:30 AM »

Since the objects have various sizes, and their y is always located at the top-left of their sprite, I prefer to use the following:

Code:
depth = -bbox_bottom;

Just have every object call that code every time its y-position changes, and it should stay in the correct range of depth.

Here, I've taken that last example you uploaded. I added in a counter (though I see you've already solved that), but not with the display. Anyhow, I fixed all the depth issues, tightened up the collision with the player a bit.

I made it so the blocks are pushed on a grid. If you want that as well, I'll show you how to implement it. For now, you can probably see how I did the blocks.

http://properundead.com/random/ag_edit.zip
Logged
Randy
Level 0
***



View Profile WWW
« Reply #16 on: June 22, 2009, 08:51:25 AM »

ChevyRay...  I owe you a huge heap of thanks for all your help.  If you ever need help with graphic work on one of your projects, feel free to ask.

I do have some questions though.  I learn best by watching and then doing.  So for me to better understand what you've done I must ask some things.

In the rock object, what does this do for it?
Code:
if (pushing){
    pushing -= 1;
    x += push_x;
    y += push_y;
    depth = -bbox_bottom;
    if (pushing == 0){
        push_x = 0;
        push_y = 0;
    }
}

In the push movement code, what does this mean?  What's with all the ifs and withs?
Code:
//Push Horz

if (movex != 0){
    pushh = instance_place(x + movex, y, o_rock);
    if (pushh){
        with (pushh){
            if (!pushing){
                if (!place_meeting(x + movex, y, o_collision)){
                    push_x = movex;
                    pushing = 8;
                }
            }
        }
    }
}
   
//Push Vert

if (movey != 0){
    pushv = instance_place(x, y + movey, o_rock);
    if (pushv){
        with (pushv){
            if (!pushing){
                if (!place_meeting(x, y + movey, o_collision)){
                    push_y = movey;
                    pushing = 8;
                }
            }
        }
    }
}

Also, for when the player has stopped walking, what does this mean?  Or, what does the double == mean?
Code:
//When player has stopped walking
if keyboard_check_released(vk_up)
{
    if (sprite_index == s_me_wup)
        sprite_index = s_me_up;
}

Sorry for all the questions.  I just want to better see what you've done and my ability to read code isn't so great yet.  One more thing... how did you become so good with GML?  Does reading the whole help section in Game Maker help?  Or is it better to just try, ask questions and study examples?

Thanks again.  I'll post a new version when I have something more to show.
Logged
ChevyRay
Guest
« Reply #17 on: June 22, 2009, 09:36:25 AM »

EDIT: my this was a huge post Epileptic... just read it from beginning to end, and slowly Tongue take your time to digest it. I tried to be as clear as possible.


Double == is just programming syntax for "is equal to". In most programming languages, you have to use this when coding comparisons. A single = usually means an assignment, and if used as an assignment will just cause you agony.

Game Maker allows single = signs for comparisons, but right now I'm branching out into other programming languages, so it helps to keep as many practices consistent through them Tongue otherwise I get confused and start screwing up when I switch between.

Okay, when you see me go:

Code:
if (variable)

This is a GML convention that I take advantage of. Basically, when you write an if-statement, the results are gonna be true or false, and the code block after is executed when it's true, right? Well, when you just write a single variable like that, it will be true if the value is greater than 0, and false otherwise.

So I'll explain this:

Code:
if (pushing){
    pushing -= 1;
    x += push_x;
    y += push_y;
    depth = -bbox_bottom;
    if (pushing == 0){
        push_x = 0;
        push_y = 0;
    }
}

So basically, as long as pushing is > 0, the following code is executed. Remember how we used movex and movey to move the character? They represent the relative x- and y position that that player should move to. Well, in the //Push Horz code, you'll see that I set push_x to the character's movex when you successfully push a block. The same happens for y.

Pushing is set to 8. So for 8 steps (because pushing -= 1 every step, right?), the block moves at your walk speed in the direction you pushed it. Since the walk speed is 2, this means that after 8 increments, it will always have moved 16 pixels, the size of the grid! This is why the block moves smoothly, but remains fixed to the grid every time it stops.

Now, for the more complicated part:

Code:
//Push Horz

if (movex != 0){
    pushh = instance_place(x + movex, y, o_rock);
    if (pushh){
        with (pushh){
            if (!pushing){
                if (!place_meeting(x + movex, y, o_collision)){
                    push_x = movex;
                    pushing = 8;
                }
            }
        }
    }
}

I'll just explain // Push Horz, because the same logic applies to // Push Vert, except for the y-values instead of x.

if (movex != 0)
This is my way of saying, "is the player moving horizontally?". Because movex represents the relative x-position to move to, if movex==0, that means that the player has not pressed a key and should not move, so why bother executing the push code?

pushh = instance_place(x + movex, y, o_rock);
instance_place is a collision check function. Basically, it checks the specified position for the type of object specified. But the useful think about this function is that, instead of returning true or false, it actually returns the instance-ID of the object it collides with! So what I do is I set the return value of the function to pushh, so now I can reference that particular o_rock instance I've run into. I use this to push the rock, but a few more things have to be checked...

if (pushh){
Remember how I said values >0 will be true in an if-statement? I'm using that trick now! When I use instance_place to reference the o_rock collision, it is supposed to return the instance-ID (usually a value from 100000+), but what if there is no instance there? In that case, the function returns noone (which is equal to -4, actually). In such a case, this if-block won't be executed, because we aren't pushing anything.

with (pushh){
If we ARE in-fact pushing something, I can use a with-statement to control the instance pushh, which references the o_rock that I am pushing and only it. If you aren't familiar with the with-statement, the GM manual explains it pretty well Smiley just look it up, it'll all come clear.

if (!pushing){
Now, remember how we set pushing to 8 when we push it, and it counts back down to 0? Well, this line makes sure that we aren't already pushing this block. If we are, then pushing will be >0, and the following block won't be executed. The ! before pushing is just the coder's way to say "if NOT pushing". So it basically gives the opposite (true->false and false->true) of what "if (pushing)" would give us.

if (!place_meeting(x + movex, y, o_collision)){
Notice the ! again, so this is a NOT check. This basically says, "if there is NOT an instance of o_collision at position (x + movex, y)". Also, realize that this code is within the with statement, so it's actually the o_rock that is executing this code! Get it? It means that the player isn't checking for o_collision, it's the o_rock that is, because this is the push code, we want to know if o_rock is able to move.

push_x = movex;
pushing = 8;

Finally, the first sets o_rock's push_x variable to the same value as our move variable. So if we were moving RIGHT when we pushed it, the block will get pushed to the right. If we were moving LEFT when we pushed it, the block will get pushed LEFT. And, as you know, pushing is set to 8 so that it moves 8 times (in increments of 2), ending up on the next grid cell.

Now, this one is quite simple:

Code:
//When player has stopped walking
if keyboard_check_released(vk_up)
{
    if (sprite_index == s_me_wup)
        sprite_index = s_me_up;
}

This is the exact same as yours, but except for this line:

if (sprite_index == s_me_wup)
Remember how before, when you were holding multiple keys and released one of them, the character would "blip", and face the wrong direction for a quick second? That's because in the release-key event for that key, this code was telling them to do that! What I did, was made it so they only changed into the standing sprite IF their current walking sprite was in the same direction! So if you're walking RIGHT and then release RIGHT, it will stop. But if you're walking RIGHT and release DOWN, nothing will happen!

Quote
One more thing... how did you become so good with GML?  Does reading the whole help section in Game Maker help?
The GM help file. The GM Help file. The GM Help file. Tongue I didn't have internet for the first 2 years when I was using Game Maker 4, and just read and read that help file. It's really useful, especially with the search functions available for you!

What I recommend is just going to the language basics section, and reading through everything. You won't digest it all at once, but some things will immediately jump out at you, and you'll know that you'll be able to use them in your code from that point on. If you need to know something specific, like saaay, changing the screen resolution... just type "resolution" into the search field, and see what pops up! Then read.

Like, go through that stuff I just explained to you there, and try some of it out on your own. I probably have 1000 GMK files sitting around that are purely files created to test out functions, try out new things, etc. I've basically been working with GM so long that I've hammered that whole help file into my head, and now I can recall most of GM's built-in functions on the fly, even with all their parameters.

It'll take awhile to learn, but like you say, downloading examples and looking at them is just fine. Just try to put into practice everything you learn, so it doesn't sink into the back of your brain, and eventually you'll memorize it like I have, and that's one less thing you have to worry about as you learn the rest of it!

Best of luck, and like I say, you're free to PM, email, or IM me anytime even if you have the simplest question. I generally respond quickly, and enjoy helping out Smiley

Best of luck!
Logged
Loren Schmidt
Level 10
*****



View Profile WWW
« Reply #18 on: June 22, 2009, 10:43:30 AM »

I just wanted to say that the game looks neat, and I think it's grand that ChevyRay is being so helpful and neighborly. Cheers. I'm sure your wife will be happy with the game.
Logged
VinceTwelve
Level 0
***



View Profile WWW
« Reply #19 on: June 26, 2009, 11:38:33 AM »

This looks so great!  I have a huge soft spot for games with a personal touch like this.  Well done.  Just don't show my wife...  Embarrassed
Logged

Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic