Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: [Request / Listing] Problem: Simple, but I don't know the best way.  (Read 3385 times)

0 Members and 1 Guest are viewing this topic.

Fox

Turnbeutelvergesser since 1988.
[Request / Listing] Problem: Simple, but I don't...
« on: April 30, 2006, 09:48:54 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 4062
It's about enemy-movement. We have an Arachnoid, that is supposed to move in one of ten cases. That works alright.
What's not working is the movement. I want him to move in any diagonal direction, and if he collides with any object, he must return in the other diagonal direction.

It's so simple, and still I don't know the best code to do... >_<
« Last Edit: February 08, 2012, 10:46:39 am by Niek »
Logged
  • Me on deviantART

GeekyLink

Re: Problem: Simple, but I don't know the best w...
« Reply #1 on: May 01, 2006, 06:56:50 pm »
Well I don't know what language you're using, but if it's visual c++ 6, visual c++ 2005 , vb 5, 6, or vb.net I can help.
Just tell me what language and you'll have the code. ;)
« Last Edit: May 01, 2006, 07:16:14 pm by GeekyLink »
Logged

Fox

Turnbeutelvergesser since 1988.
Re: Problem: Simple, but I don't know the best w...
« Reply #2 on: May 01, 2006, 07:52:46 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 4062
Oops.

It's GM5. (GM5.3a)
Logged
  • Me on deviantART

GeekyLink

Re: Problem: Simple, but I don't know the best w...
« Reply #3 on: May 01, 2006, 09:24:30 pm »
Sorry I can't help then I only program with visual c++ 6, visual c++ 2005 , vb 5, 6, or vb.net
I don't know how this will work but you can try it.
This code is actualy for vb.net(I assumed gm is kind of simulal)
the quotes tell you what is going on

imgBad stands for badguy
BadDire1 keeps a value on which direction the badguy is going(it is a string)

First diagonal
Code: [Select]
'sees which direction enemy is supossed to go
if BadDire1 = "UpRight" then
'this makes enemy move up and right
imgBad.left += 1
imgBad.top -= 1
'+= means the current value + the following integer
end if

for revirsing
This assumes you already made a collision ditector
Code: [Select]
'An if stament for collision
if BadDire1 = "UpRight"
'switches direction
BadDire1 = "DownLeft"
end if

Hope this helps.
« Last Edit: May 02, 2006, 12:47:20 pm by GeekyLink »
Logged

Goodnight

Once and future Captain
Re: Problem: Simple, but I don't know the best w...
« Reply #4 on: May 02, 2006, 04:32:19 pm »
  • With a Capital G
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 706
direction += 180

That seems too simple... I must be misunderstanding...? :D
Logged
Re: Problem: Simple, but I don't know the best w...
« Reply #5 on: May 02, 2006, 04:47:41 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2245
direction += 180

That seems too simple... I must be misunderstanding...? :D
i interpretted it the same way you did
Logged

Fox

Turnbeutelvergesser since 1988.
Re: Problem: Simple, but I don't know the best w...
« Reply #6 on: May 02, 2006, 06:53:23 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 4062
Sorry I can't help then I only program with visual c++ 6, visual c++ 2005 , vb 5, 6, or vb.net
I don't know how this will work but you can try it.
This code is actualy for vb.net(I assumed gm is kind of simulal)
the quotes tell you what is going on

imgBad stands for badguy
BadDire1 keeps a value on which direction the badguy is going(it is a string)

First diagonal
Code: [Select]
'sees which direction enemy is supossed to go
if BadDire1 = "UpRight" then
'this makes enemy move up and right
imgBad.left += 1
imgBad.top -= 1
'+= means the current value + the following integer
end if

for revirsing
This assumes you already made a collision ditector
Code: [Select]
'An if stament for collision
if BadDire1 = "UpRight"
'switches direction
BadDire1 = "DownLeft"
end if

Hope this helps.
I think that's not close enough to GM... but thanks! ^_^

direction += 180

That seems too simple... I must be misunderstanding...? :D
direction += 180

That seems too simple... I must be misunderstanding...? :D
i interpretted it the same way you did
Alright, that's a good idea... You see it IS easy, but I didn't know it. XD What would you recommend I use as a code so that it indicates the collision with ANY object?
Logged
  • Me on deviantART
Re: Problem: Simple, but I don't know the best w...
« Reply #7 on: May 02, 2006, 08:06:24 pm »
  • =/
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2284
collision_point(x,y,obj,prec,notme)

Right from the gm manuel. Just put "all" were it says obj.
Logged

Goodnight

Once and future Captain
Re: Problem: Simple, but I don't know the best w...
« Reply #8 on: May 03, 2006, 12:29:53 am »
  • With a Capital G
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 706
Collision functions in GM are pretty confusing.. there's a lot of them with minor differences.. but for detecting collisions on the object itself, place_meeting(x,y,all) will work better than collision_point(), because with the latter, you could have another object touching this one but NOT overlapping at the exact (x,y) point, and it wouldn't detect that.
Logged
Re: Problem: Simple, but I don't know the best w...
« Reply #9 on: May 03, 2006, 12:31:59 am »
  • =/
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2284
Collision functions in GM are pretty confusing.. there's a lot of them with minor differences.. but for detecting collisions on the object itself, place_meeting(x,y,all) will work better than collision_point(), because with the latter, you could have another object touching this one but NOT overlapping at the exact (x,y) point, and it wouldn't detect that.
Your so good with Gm yet I havn't seen (or remember seeing) a fan-game by you. Is there a reason for this?
Logged
Re: Problem: Simple, but I don't know the best w...
« Reply #10 on: May 03, 2006, 05:44:24 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 4588
What about that FS-type game.... :/
Logged
the a o d c

cloudsquall

Re: Problem: Simple, but I don't know the best w...
« Reply #11 on: May 03, 2006, 09:10:11 pm »
Building on what Goodnight said,in Game Maker applies the general rule that whenever you see the word 'position' in a (collision) function,it means
that exact point you type as a parameter,whereas 'place' means the instance that calls the function  when it is in the position you type.

I know the above is confusing(english is not my native language you know) so here's an example:
Take place_meeting and position_meeting for example.
If,say, objLink calls the function place_meeting,it will check if Link collides with the object you specify,when placed at the x and y you specify.
If he calls position_meeting,it will check if the point(the dot) at the coordinates you specify meets the object you specify.

So it goes like this:
==========================
| for the whole object |   for a point       |
==========================
|       place_free         |          ---           |
-----------------------------------------------
|    place_meeting      | position_meeting|
------------------------------------------------
|      place_empty      |   position_empty |
==========================

As you can see place_free doesn't have an equivalent with position.I don't know why,but who could find a use for it?:)

Whew,probably a lot and mostly irrelative ,but I really felt like helping.
Logged
Re: Problem: Simple, but I don't know the best w...
« Reply #12 on: May 03, 2006, 10:28:08 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1635
The reason that there is no "equivalent" for place_free is that place_empty takes into account non-solid objects, yet place_free is just for solid objects. Since you can't have a solid or not solid point, it wouldn't make any sense to have a collision check for a point that took into account only solid objects, because there is no such thing.

Hence the answer.
Logged

Fox

Turnbeutelvergesser since 1988.
Re: Problem: Simple, but I don't know the best w...
« Reply #13 on: May 04, 2006, 03:07:02 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 4062
Yey! It works now! :D Thanks you guys! ^______________^
Logged
  • Me on deviantART
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.315 seconds with 62 queries.

anything