Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411515 Posts in 69380 Topics- by 58436 Members - Latest Member: GlitchyPSI

May 01, 2024, 05:21:34 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Game Maker for Beginners: Part III
Pages: 1 ... 5 6 [7] 8 9 10
Print
Author Topic: Game Maker for Beginners: Part III  (Read 129058 times)
Kneecaps
Level 3
***



View Profile
« Reply #120 on: March 21, 2009, 02:07:24 PM »

I think I just found another solution, although it probably is really slow.  The idea is that I would make a surface with the rotated sprite on it, and I would create a transparent sprite from that surface, which I would then set as the original object's collision mask.
Logged
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #121 on: March 21, 2009, 04:10:29 PM »

That sounds very slow, yes. But it depends on how often the sprites are rotated. If you rotate it every step, it'd be painfully slow, whereas if you rotate them only once when they are created and they don't constantly rotate, it might work.
Logged

Kneecaps
Level 3
***



View Profile
« Reply #122 on: March 21, 2009, 04:13:00 PM »

That sounds very slow, yes. But it depends on how often the sprites are rotated. If you rotate it every step, it'd be painfully slow, whereas if you rotate them only once when they are created and they don't constantly rotate, it might work.
It turned out to have incredible slowdown at various intervals since the objects are being rotated each step.  Oh well. Shrug
Logged
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #123 on: March 21, 2009, 04:14:29 PM »

You may want to ask this question on the GMC "advanced" forums, chance are someone may know a good way to do this there. There are more experts on Game Maker there than here.
Logged

Kneecaps
Level 3
***



View Profile
« Reply #124 on: March 21, 2009, 04:20:38 PM »

KNEECAPS WINS THE GENIUS AWARD FOR TODAY Durr...?

Edit: Okay, I figured it out.  If you want a sprite mask to rotate with the sprite, use the image_angle variable instead of trying to be fancy and using your own functions and variables.  It will save you several hours of frustration.
« Last Edit: March 21, 2009, 05:27:54 PM by Kneecaps » Logged
Katamaran
Level 0
***


View Profile
« Reply #125 on: March 22, 2009, 11:14:40 PM »

wow, that was seriously fun. This was my first GM program, and indeed my first programmed game (I've worked on art for games before, but not on the hard coding side). I didn't stray too far from the example in the tutorial visually, but I did get 2 types of enemies that move in the y, thanks to the advice in the thread, and one of them even shoots!

I'm really looking forward to the next one



one thing to note - I could never get the ring guys to move how I wanted them to. I wanted them to move in a sine formation, gradually up then down - but all I could get is them to bounce off the extremes and slow down in the middle.


this was the movement code I used. if someone could tell me where I boobed up, i'd be very appreciative  Well, hello there!Hand Thumbs Up Right
Quote
x -= xVel;

if (i < 40)
{
    i += 1;
    y += yVel;
    yVel -= .1;
}
else
{
    if (i < 80)
    {
        i += 1;
        y -= yVel;
        yVel += .1;
    }
    else
    {
        if (i < 120)
        {
            i += 1;
            y -= yVel;
            yVel -= .1;
        }
        else
        {
            if (i < 160)
            {
                i += 1;
                y += yVel;
                yVel += .1;
            }else if (i == 160)
            {
                i = 0;
            }
        }
    }   
}
Logged
GregWS
Level 10
*****


a module, repeatable in any direction and rotation


View Profile
« Reply #126 on: March 22, 2009, 11:44:27 PM »

I've done something similar before, and I just used the sine function.

Here's part of my step event code for a bullet that moves in a sine wave:
Quote
x -= 2;
y = 10*sin((pi/18)*(orig_x-x-(pi/4))) + orig_y;

orig_x and orig_y are the x and y coordinates of where the bullet was created.

Each step the bullet moves left by 2, and the y has some crazy transformation shit done on it (note: I did this code back when I was doing lots of math in my life, and probably did some formula tweaking with my graphing calculator or just some classic guess and test).

Wait, OK, I think I remember how all the y stuff worked: each step I found the y value of the object based on it's x value.  I find out where it sits on a sine wave that starts from the orig_x value by comparing that orig_x and the current x.  The stuff with pi is just to tweak how it the function looks, because sine usually goes from -1 to 1, and obviously the max y values generated should fall outside of that.  orig_y is added, because the generated y value will be positive and negative numbers, so we want those numbers to fall on either side of the creation point, not the actual y = 0 line.

OK, hopefully that made sense.  If not, don't hesitate to ask.
Logged
GregWS
Level 10
*****


a module, repeatable in any direction and rotation


View Profile
« Reply #127 on: March 22, 2009, 11:47:14 PM »

Oh, yes, and make sure to introduce yourself in the Obligatory Introduce Yourself Thread!  Smiley

http://forums.tigsource.com/index.php?topic=45.0
Logged
Derek
Bastich
Administrator
Level 10
******



View Profile WWW
« Reply #128 on: March 27, 2009, 02:30:03 AM »

Wow, Katamaran, that looks fantastic!  Keep us updated. Beer!

I'll try to start working on the next tutorial after all this GDC madness is over.
Logged
Levin
Level 1
*



View Profile
« Reply #129 on: March 28, 2009, 04:32:32 AM »

I'll try to start working on the next tutorial after all this GDC madness is over.

great news Smiley I'll waiting for it. For now, take a rest  Coffee
Logged
Katamaran
Level 0
***


View Profile
« Reply #130 on: April 04, 2009, 07:43:32 PM »

thanks for the support guys Smiley

with some trial and error I made my ship bank and have a "floater" feel to it, with acceleration and deceleration.

I think I'm done on this one for now (until the next tutorial naturally :p)

here's the .exe and source if anyone was interested:
http://www.sendspace.com/file/zo9c9x

thanks again, this has been seriously entertaining
Logged
Katamaran
Level 0
***


View Profile
« Reply #131 on: April 06, 2009, 05:22:53 PM »

I just found a bug that makes the ship get stuck to the top and bottom of the screen. I could just bounce the player away from the walls when the ship hits them but i'd really like to figure out why it does that. i'm fairly sure it's because the sprite is somehow moving outside the bounds of the view
Logged
Glyph
Level 10
*****


Relax! It's all a dream! It HAS to be!


View Profile
« Reply #132 on: April 06, 2009, 06:15:40 PM »

I just found a bug that makes the ship get stuck to the top and bottom of the screen. I could just bounce the player away from the walls when the ship hits them but i'd really like to figure out why it does that. i'm fairly sure it's because the sprite is somehow moving outside the bounds of the view
Might have to do with the floaty physics. You could set the vertical acceleration variable to 0 when you perform the code to limit the player from leaving the screen. But it really all depends on how you did the system/boundaries and what behavior is exhibited.
Logged


Katamaran
Level 0
***


View Profile
« Reply #133 on: April 06, 2009, 07:15:35 PM »

well, this is the code block that concerns y movement
Quote
// controls y speed
if (keyboard_check(vk_up))
{
    y_spd = max( y_spd - accl, -max );   
   
    sprite_index = sPlayerBankLeft;
}

if (keyboard_check(vk_down))
{
    y_spd = min( y_spd + accl, max );
   
    sprite_index = sPlayerBankRight;
}

if (!keyboard_check(vk_up) && !keyboard_check(vk_down)) //if the player does not press up or down, slow the ship down
{
    if (y_spd < 0) y_spd = min(y_spd + drag, 0);
   
    if (y_spd > 0) y_spd = max (y_spd - drag, 0);
   
     sprite_index = sPlayerShip;

}

//moves the ship if within room bounds
if ( (y => 0) && (y + 12 <= room_height) )y += y_spd;

edit: thanks to ChevyRay for his excellent platformer engine, learned a lot from that Smiley
« Last Edit: April 06, 2009, 07:44:21 PM by Katamaran » Logged
Glyph
Level 10
*****


Relax! It's all a dream! It HAS to be!


View Profile
« Reply #134 on: April 06, 2009, 07:44:57 PM »

well, this is the code block that concerns y movement
Quote
// controls y speed
if (keyboard_check(vk_up))
{
    y_spd = max( y_spd - accl, -max );   
   
    sprite_index = sPlayerBankLeft;
}

if (keyboard_check(vk_down))
{
    y_spd = min( y_spd + accl, max );
   
    sprite_index = sPlayerBankRight;
}

if (!keyboard_check(vk_up) && !keyboard_check(vk_down)) //if the player does not press up or down, slow the ship down
{
    if (y_spd < 0) y_spd = min(y_spd + drag, 0);
   
    if (y_spd > 0) y_spd = max (y_spd - drag, 0);
   
     sprite_index = sPlayerShip;

}

//moves the ship if within room bounds
if ( (y => 0) && (y + 12 <= room_height) )y += y_spd;
I would say because there's no precaution to stop the player from moving outside the room, and no code to make him move when he is. Set a limitation code somewhere-
Code:
//movement limitation code
if y<0 {y=0; y_spd=0};
if y+12>room_height {y=room_height-12; y_spd=0};
Not sure what y_spd is there, but I assume it's all for the floaty physics. Of course, you have "accl" and "drag" and other stuff too, so I'm not sure what's going on there. Basically the y_spd=0 represents setting the floating motion to 0.
Logged


Katamaran
Level 0
***


View Profile
« Reply #135 on: April 06, 2009, 07:51:56 PM »

 Durr...? thanks, that's it exactly. with all my shuffling around with the code I accidentally took that part out.
Logged
Super Joe
BANNED
Level 9
*

let's go


View Profile
« Reply #136 on: April 12, 2009, 05:41:55 PM »

derek yu please teach me to make game
Logged
JoeHonkie
Level 8
***


RIP Major Sebastian Bludd


View Profile WWW
« Reply #137 on: April 13, 2009, 10:10:57 AM »

Was the tilemap supposed to use 16x16 tiles or 32x32?  I found the latter easier.

Man, good tutorials.

EDIT: hahaaa. I'm retarded.  I copied and pasted the image you had linked in the article so the tiles were double sized.  Don't listen to me, man.
« Last Edit: April 13, 2009, 10:53:05 AM by JoeHonkie » Logged
Katamaran
Level 0
***


View Profile
« Reply #138 on: April 13, 2009, 03:23:28 PM »

oh man, I did the exact same thing
Logged
Ted
Level 4
****


View Profile WWW
« Reply #139 on: June 02, 2009, 09:12:43 PM »

These are really helpful man.  Thanks.
 Hand Thumbs Up Left Hand Metal LeftWizardHand Metal Right Hand Thumbs Up Right

Logged

Pages: 1 ... 5 6 [7] 8 9 10
Print
Jump to:  

Theme orange-lt created by panic