need code please, this my code:
{
if (hspeed == 0) 0
{
if (random(3)<1 and place_free(x-4,y))
{
hspeed = -4;
vspeed = 0; }
if (random(3)<1 and place_free(x+4,y))
{ hspeed = 4; vspeed = 0;}
need code please, this my code:
{
if (hspeed == 0) 0
{
if (random(3)<1 and place_free(x-4,y))
{
hspeed = -4;
vspeed = 0; }
if (random(3)<1 and place_free(x+4,y))
{ hspeed = 4; vspeed = 0;}
pacman ghosts don't move at random directions; in pacman you don't even need to move by finite numbers like 4 and check for collisions; you should have a graph of all intersections and build the ai on that. Although from your question i deduce you lack the basics for separating what is seen by what happens in the background.
Hint: most games aren't what the user can see; tetris and minesweeper are just bidimensional arrays, pacman is a graph, card games are stacks and lists. The only "simple" game i can think of where what you see is exactly what happens is pong. https://www.youtube.com/watch?v=qwhXIzNrb9w