Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411421 Posts in 69363 Topics- by 58417 Members - Latest Member: JamesAGreen

April 18, 2024, 06:55:37 AM

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


3 Months Sober


View Profile WWW
« Reply #140 on: June 09, 2009, 12:28:40 AM »

Oh wow, I just learned a bunch from this thread.  Kiss

BTW Derek, we share the same first name.  Noir
Logged

Sit down and relax,
Keeping focus on your breath,
This may take a while.

relsqui
TIGBaby
*



View Profile WWW
« Reply #141 on: June 19, 2009, 01:27:33 AM »

Thanks, Derek; this is exactly what I was looking for when I came here and it was very helpful. I'm looking forward to reading the next one.

I adapted what I learned in these tutorials to make a very basic platformer--movement with left/right, z jump, x shoot, q quit--and a small tileset to populate it with. With any luck I'll develop it into something fun, but in the meantime, if anyone following was going to do the same thing, let me save you some trouble:

http://chiliahedron.com/relsqui.gmk

The player physics are a matter of taste, of course, but there are a bunch of constants in the player creation code which you can tweak. I think they're all self-explanatory. I didn't make the sprite, although I did animate it, so permission is not mine to give to use it elsewhere. Feel free to use the tiles, though.
Logged
shipwreck
Level 0
**


Run and shoot, shoot and run.


View Profile WWW
« Reply #142 on: August 22, 2009, 05:55:11 AM »

Dereks ftw!

Wow wow wow! This is some cool stuff. After dabbling a bit I finally decided to dive in. While, of course, I have pipe dreams of being an uber coder I have to crawl before I can walk and right now I'm crawling quite slowly whilst walking seems a far and distant possibility.

That said, I'd like to be able to 'speak' the language of GM so I need this translated. I'm trying to wrap my head around a particular bit of code:
Code:
// Revive the player if he dies
if (not instance_exists(oPlayerShip))
{
    if (reviveTimer > 0) reviveTimer -= 1;
    else instance_create(view_xview[0]+32, view_yview[0]+112, oPlayerShip);
}
else
{
    oPlayerShip.x += 1;
}

Essentially this is saying "Check to make sure the playership exists. If it doesn't then check the revivetimer. If the revivetimer (which I'm assuming is a variable in another object or just understood by GM?) is not zero then tick it down to zero. Otherwise if it is at zero, make another playership." Right?

I am stuck on
Code:
else
{
    oPlayerShip.x += 1;
I realize it's an "if else" statement but I can't figure out what it's saying. Is it just, 'otherwise the player ship still exists'? Halp! My brains!

And great little thingy there, relsqui! Way to go above and beyond.
Logged
davidp
Level 6
*



View Profile WWW
« Reply #143 on: August 22, 2009, 06:32:34 AM »

if ship doesn't exist do stuff, otherwise if ship still exist, move it one pixel right
Logged

shipwreck
Level 0
**


Run and shoot, shoot and run.


View Profile WWW
« Reply #144 on: August 22, 2009, 01:14:51 PM »

That helps, thanks.
Logged
rrrowdy
Level 0
***



View Profile WWW
« Reply #145 on: August 27, 2009, 01:33:44 AM »

I've got a question regarding "enemy" motion that I figure is on a level appropriate for this thread (basically I'm a total newbie to Game Maker, this is the first game I've ever made).

How would one go about programming in automatic movement of an enemy based upon where a player is? For example, a zombie is triggered by the player moving closer to it.

Hmm. Eternal thanks to anybody who can help.
Logged
Loop Gain
Level 0
**



View Profile
« Reply #146 on: August 27, 2009, 02:04:28 PM »

How would one go about programming in automatic movement of an enemy based upon where a player is? For example, a zombie is triggered by the player moving closer to it.

Off the top of my head, if you have a player object and one or more enemy objects, you could put something like this in the step event of the enemy object:

Code:
player_center_x = player.x + player.sprite_width/2;
player_center_y = player.y + player.sprite_height/2;
enemy_center_x = x + sprite_width/2;
enemy_center_y = y + sprite_width/2;

// How close the player object must be to an enemy object to activate the latter's movement.
trigger_distance = 50;

distance_to_player = point_distance(player_center_x, player_center_y, enemy_center_x, enemy_center_y);

if (distance_to_player <= trigger_distance){
  // Move towards the player's location.
  // This is very basic movement (it also assumes a top-down view), but you get the idea.
  if (player_center_x > enemy_center_x){
    x += 1;
  }
  else if (player_center_x < enemy_center_x){
    x -= 1;
  }

  if (player_center_y > enemy_center_y){
    y += 1;
  }
  else if (player_center_y < enemy_center_y){
    y -= 1;
  }
}

Hope that helps!
Logged
rrrowdy
Level 0
***



View Profile WWW
« Reply #147 on: August 27, 2009, 03:00:36 PM »

How would one go about programming in automatic movement of an enemy based upon where a player is? For example, a zombie is triggered by the player moving closer to it.

Off the top of my head, if you have a player object and one or more enemy objects, you could put something like this in the step event of the enemy object:

Code:
player_center_x = player.x + player.sprite_width/2;
player_center_y = player.y + player.sprite_height/2;
enemy_center_x = x + sprite_width/2;
enemy_center_y = y + sprite_width/2;

// How close the player object must be to an enemy object to activate the latter's movement.
trigger_distance = 50;

distance_to_player = point_distance(player_center_x, player_center_y, enemy_center_x, enemy_center_y);

if (distance_to_player <= trigger_distance){
  // Move towards the player's location.
  // This is very basic movement (it also assumes a top-down view), but you get the idea.
  if (player_center_x > enemy_center_x){
    x += 1;
  }
  else if (player_center_x < enemy_center_x){
    x -= 1;
  }

  if (player_center_y > enemy_center_y){
    y += 1;
  }
  else if (player_center_y < enemy_center_y){
    y -= 1;
  }
}

Hope that helps!

That helps SO MUCH you have no idea. I'll love you forever. I'm getting a Loop Gain tattoo as I type this.
Logged
nylos
Level 0
*


View Profile
« Reply #148 on: September 17, 2009, 11:28:41 AM »

Awesome work Derek :D.
Are there any turtorials like this for other things like rpgs or jump 'n' runs?
Logged
Destral
Level 10
*****


Climbing that mountain...


View Profile WWW
« Reply #149 on: September 19, 2009, 02:48:27 PM »

Thanks Derek for the tutorials, and everyone else who's been helping out with questions. Definitely a great help learning GML. I've been doing some GM tutorials using the drag and drops, but figured I really should learn GML as well. I'll post some screenies and such of my progress sometime this weekend.
Logged

Currently working on: Sword Surfer
givecake
Level 0
**


View Profile
« Reply #150 on: April 25, 2010, 09:47:14 PM »

Hello all.
I was following this tut today, and got stuck on creating walls. I'm using the newest version of game maker, 8.0 and when I place the oWall object on the map, I get a little blue circle and red question mark, like the oGame object. Is there an attribute in the oWall settings that must be added somehow? I've followed the tutorial exactly, as far as I can see, and the only things I've changed with oWall, was the name and uncheck 'Visible' to make it invisible (although it never had a sprite, so it would be invisible anyways :O ).

Thanks for any help Smiley
Robin
Logged
Ted
Level 4
****


View Profile WWW
« Reply #151 on: April 26, 2010, 12:04:48 AM »

If an object doesn't have a sprite assigned to it then it will use that blue circle with the red question mark (which will not be visible when the game runs).  If you open the oWall object you can change its sprite by clicking where it says <no sprite> and selecting a new one.
Logged

givecake
Level 0
**


View Profile
« Reply #152 on: April 26, 2010, 02:10:14 AM »

Thanks Wink Got it sorted!
Logged
antymattar
Level 5
*****


Has earned the contemporary *Banned* medal


View Profile
« Reply #153 on: September 29, 2010, 09:16:47 AM »

So just one question Derek. Are you seriously that guy with a mustache in your avatar? If so then you are sooo totally awesome!  Hand Shake Left   WTF   Hand Metal Right
Logged

imaginationac
Level 2
**


Makin' games instead of makin' money.


View Profile WWW
« Reply #154 on: September 29, 2010, 12:09:18 PM »

That would be awesome, but there's an actual picture of himself in the first post of the Obligatory Introduce Yourself thread.
Logged

Youtube channel | Charger! Dev Log
              
smokingspoon
Level 0
**


Fran


View Profile WWW
« Reply #155 on: October 15, 2010, 03:20:25 PM »

Those tutorial are incredible...

The best I've seen.

Thank you very much mister Derek Yu,
you gave me hope after all those years Tears of Joy haha
« Last Edit: October 15, 2010, 04:02:04 PM by smokingspoon » Logged

Check out my creations https://twitter.com/Smokingspoon
I'm also known as Xena.
antymattar
Level 5
*****


Has earned the contemporary *Banned* medal


View Profile
« Reply #156 on: October 27, 2010, 02:52:49 AM »

I ma making a game from this. Can I use and edit the tileset? I am going to give you credit.
Logged

tatthi
Level 0
*


I Feel Fantastic


View Profile
« Reply #157 on: December 22, 2010, 09:30:51 AM »

Hey I can't find the views in Game Maker 8. Anyone want to help me? Tongue Panda
Logged
GZ
Level 1
*



View Profile WWW
« Reply #158 on: December 22, 2010, 12:43:14 PM »

Hey I can't find the views in Game Maker 8. Anyone want to help me? Tongue Panda
File>Advanced Mode

Make sure it's on, otherwise many things are hidden.
Logged

tatthi
Level 0
*


I Feel Fantastic


View Profile
« Reply #159 on: December 23, 2010, 07:19:36 AM »

Well now I feel stooped. Seems like it switches itself off whenever you close the application.  Shrug

Thanks! Tongue
Logged
Pages: 1 ... 6 7 [8] 9 10
Print
Jump to:  

Theme orange-lt created by panic