Log in
Search
GameML File Sharing
USERNAME: gamemladmin@gmail.com PASSWORD: gamemlsite Upload Here: https://gameml.forumotion.com/GameML-File-Sharing-h3.htmPlease add only games.Worm/Snake code
+2
Sparx the Cy-Wolf
GoldenBeastStudios
6 posters
:: Game Making :: Game Maker Help :: Game Dev. Q&A :: GML help (Coding)
Page 1 of 1
Worm/Snake code
I'm attempting to make a worm/snake kinda enemy, but I can't seem to get the body segments to follow the head in a logical way. I'm basically trying to use the xprevious and yprevious of the head, except it needs to be the 30th previous x and y, so that body segments follow the head, but not right next to it (thus reducing the number of objects needed). Here's a pic of what I'm trying to do:
Any pointers anyone?
John
Any pointers anyone?
John
Re: Worm/Snake code
It's a long shot, but have you thought about usig alarms on each segment that differes for each one, for instance the second segment would differ in time from the first one by, let's say "10" beofre it does the same "action" when following the first, while the third one would differ by "20" from the first and....you get the idea?
Re: Worm/Snake code
to difficult. Probably will not work. I say you just make several segments as different objects. make one segment move towards another segment like: for part3 move_towards_point(part2.x,part2.y,3) then make qa mask for all of them andif it collides with that object, stop following. theres an AI gm7 video for a AI partner. It has how to keep distance, use that following code(all of it) in your thing!
Re: Worm/Snake code
i did this once to give a trail to the mouse, that the trail was just a line.
it involves alarms and variables.
ok simple on alarm0 (which is 10 steps long): jump part1 to x1,y1 then jump part2 to x2,y2 ect... then set x3,y3 to x2,y2 then x2, y2 to x1,y1 then x1,y1 to whatever the main object is.
it involves alarms and variables.
ok simple on alarm0 (which is 10 steps long): jump part1 to x1,y1 then jump part2 to x2,y2 ect... then set x3,y3 to x2,y2 then x2, y2 to x1,y1 then x1,y1 to whatever the main object is.
fooey- Moderator
- Posts : 1422
Points : 55740
GameML Reputation : 1
Join date : 2009-07-10
Age : 29
Location : here
Re: Worm/Snake code
Woah! Looks tough! I could never do this! Tell me how to do it when your done!
65loconut- GameML Noob
- Posts : 8
Points : 52205
GameML Reputation : 1
Join date : 2010-01-31
Re: Worm/Snake code
Usually I'm a man of action but this has got me fucked.
Using xprevious would pretty much make them right inside each other, but all of them moving towards the next one will probably not work that way...
Using xprevious would pretty much make them right inside each other, but all of them moving towards the next one will probably not work that way...
:: Game Making :: Game Maker Help :: Game Dev. Q&A :: GML help (Coding)
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|