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.A simple code
5 posters
:: Game Making :: Game Maker Help :: Game Dev. Q&A :: 2d game Help
Page 1 of 1
A simple code
I have a new code priblem. There seem to be no errors with this code when I check. Bt when I start upo the game It has one;
- Code:
if player.x < x
{sprite_index = spr_bad_guy
hspeed = 5}
else
{sprite_index = spr_bad_guya
hspeed = -5}
if position_meeting[x+2,y,wall] or position_meeting[x-2,y,wall]
vspeed = -10
Last edited by The SNIC on Sat Sep 12, 2009 8:33 am; edited 3 times in total (Reason for editing : Cuz there's a new problem w? a different code)
Re: A simple code
*sneeze*
fooey- Moderator
- Posts : 1422
Points : 55590
GameML Reputation : 1
Join date : 2009-07-10
Age : 29
Location : here
Re: A simple code
Have you tried this: (put in boss step event or wherever)
- Code:
if distance_to_point(CHARACTOR.x,CHARACTOR.y) = PERFERED_DISTANCE
{PUT_ACTIONS HERE}
Re: A simple code
That's a lot less complex than my original but, the "action" part is difficult I can't get the character to follow him! Or go down without him moving but I still want it to pause.
Re: A simple code
- Code:
if distance_to_point(object0.x,object0.y) = 11
{
for (object0) x = boss.x
for (object0) y = object0.y
for (object0) vspeed = 20
vspeed = 20
}
Re: A simple code
Try changing "for" to "with" ?The SNIC wrote:problem: ERROR at line 3 pos 15: assignment operater expected.
- Code:
if distance_to_point(object0.x,object0.y) = 11
{
for (object0) x = boss.x
for (object0) y = object0.y
for (object0) vspeed = 20
vspeed = 20
}
Re: A simple code
um...yes i agree
fooey- Moderator
- Posts : 1422
Points : 55590
GameML Reputation : 1
Join date : 2009-07-10
Age : 29
Location : here
Re: A simple code
I agree as well. The for statement is a looping statement with different syntax as well as function. When using the "with" statement format it like this:
- Code:
if distance_to_point(object0.x,object0.y) = 11
{
with(object0)
{
x = boss.x
y = object0.y
vspeed = 20
}
vspeed = 20
}
Topic recap:
I have a new code priblem. There seem to be no errors with this code when I check. But when I start up the game It has one:
Code:
if player.x < x
{sprite_index = spr_bad_guy
hspeed = 5}
else
{sprite_index = spr_bad_guya
hspeed = -5}
if position_meeting[x+2,y,wall] or position_meeting[x-2,y,wall]
vspeed = -10
Code:
if player.x < x
{sprite_index = spr_bad_guy
hspeed = 5}
else
{sprite_index = spr_bad_guya
hspeed = -5}
if position_meeting[x+2,y,wall] or position_meeting[x-2,y,wall]
vspeed = -10
Re: A simple code
try changing the "[" to "("The SNIC wrote:I have a new code priblem. There seem to be no errors with this code when I check. But when I start up the game It has one:
Code:
if player.x < x
{sprite_index = spr_bad_guy
hspeed = 5}
else
{sprite_index = spr_bad_guya
hspeed = -5}
if position_meeting[x+2,y,wall] or position_meeting[x-2,y,wall]
vspeed = -10
Similar topics
» Simple 2D Rain Code-Lite
» How do you make simple blood in a game?
» Turret code
» Worm/Snake code
» Simple Codes by 3d
» How do you make simple blood in a game?
» Turret code
» Worm/Snake code
» Simple Codes by 3d
:: Game Making :: Game Maker Help :: Game Dev. Q&A :: 2d game Help
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|