Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411412 Posts in 69360 Topics- by 58415 Members - Latest Member: sophi_26

April 15, 2024, 10:28:57 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsTen random tips for Gamemaker
Pages: [1]
Print
Author Topic: Ten random tips for Gamemaker  (Read 3613 times)
Sean Raia
Level 0
***

Iterate!


View Profile
« on: July 05, 2013, 01:50:43 PM »

Made this video this morning and then realized how randomly scattered the tips are.

Oh well, give it a watch, maybe you'll learn something new!

 Smiley

http://www.youtube.com/watch?v=iok4gK51KGo&feature=youtu.be
Logged

Wanna talk? I'm always looking to meet and network with other indies!
Shoot me an email at
[email protected]

http://seanraia.blog.com/
Benearg
Level 0
**



View Profile WWW
« Reply #1 on: July 14, 2013, 08:23:21 AM »

I am total n00b with gamemaker and I appreciate these kinds of tutorials. Now, I don't quite get how to write my own movement scripts, since I learned through code to use vspeed, hspeed and direction, so if you could explain this further would be really useful. I am currently using if X or Y is collision free then jump to x or y (-x or -y). There's anything better than this?
Secondly, I don't get the "floored sprites" technique. Is to avoid bluring pixels?

Anyway, I enjoyed your 2 videos since they are good source for learning.

Logged
Xion
Pixelhead
Level 10
******



View Profile WWW
« Reply #2 on: July 15, 2013, 08:30:42 PM »

Benearg; you can define your own speed variables like:

Code:
xspeed = 0;
yspeed = 0;

and then when you want to increment them instead of going hspeed += 1 or whatever you'd go xspeed += 1.
when it comes time to actually move the object you'd just once in the step event do something like

Code:
if place_free(x+xspeed,y+yspeed) {
  x = x+xspeed;
  y = y+yspeed;
  }

That'd actually be a pretty buggy and imprecise way of doing it but the basic idea is present. And now you can make your own collision stuff that's way more accurate than the default gm stuff. You'd probly wanna do something more like
Code:
repeat(abs(xspeed) {
  if place_free(x+sign(xspeed),y)
    x += sign(xspeed);
  else
    xspeed = 0;
  }
repeat(abs(yspeed) {
  if place_free(x,y+sign(yspeed))
    y += sign(yspeed);
  else
    yspeed = 0;
  }
or something, maybe. I think that should work. Possibly.
« Last Edit: July 17, 2013, 05:42:47 PM by Xion » Logged

Sean Raia
Level 0
***

Iterate!


View Profile
« Reply #3 on: July 17, 2013, 02:37:08 PM »

Im glad you liked the videos!

I was planning on doing a basic top down movement tutorial followed by a platformer movement tutorial this weekend.

Logged

Wanna talk? I'm always looking to meet and network with other indies!
Shoot me an email at
[email protected]

http://seanraia.blog.com/
JigsawDisease
Level 0
***



View Profile
« Reply #4 on: July 22, 2013, 08:03:41 AM »

You'd probly wanna do something more like
Code:
repeat(abs(xspeed) {
  if place_free(x+sign(xspeed),y)
    x += sign(xspeed);
  else
    xspeed = 0;
  }
repeat(abs(yspeed) {
  if place_free(x,y+sign(yspeed))
    y += sign(yspeed);
  else
    yspeed = 0;
  }
or something, maybe. I think that should work. Possibly.

wouldnt that code mean you would stop 5 pixels away from an object if you were going at 5 pixels per frame? im a code newbie.
Logged

Rat Casket
Level 10
*****


i can do what i want


View Profile WWW
« Reply #5 on: July 31, 2013, 12:38:36 PM »

It shouldn't. Sign returns either 1 or -1 regardless of the number its actually looking at.
Logged

JigsawDisease
Level 0
***



View Profile
« Reply #6 on: July 31, 2013, 06:28:54 PM »

ah thanks a lot, i think i might use sign in my own collision detection
Logged

RyanHuggins
Level 1
*



View Profile WWW
« Reply #7 on: August 06, 2013, 05:30:17 PM »

sign(number) is one of the best things I've discovered in GM. Haha. I used to have variables to determine what direction the player was in at any given time (left or right) and now I can just base it on the sign value of the movement.

the max() and min() functions are also super helpful for equilibrium (and setting a speed to its max value or returning it to 0 instead of using a bunch of if statements. These have really cleaned up and condensed my code recently.

As far as the code...

Code:
repeat(ceil(abs(xspeed)))
{
   if (!place_meeting(x + sign(xspeed), y, par_solid)
   {
      x += sign(xspeed);
   }
}

...this is a really functional way to deal with moving objects in a basic way and handling collisions without messy loops to move to contact (or GM's awful function), but some limitations I find is that it's hard/impossible to do movement speeds that aren't integers.

Luckily, gradual increases/decreases in movement still work pretty well, you just can't have an object that moves at 2.5 pixels a step (easily).
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic