Jump to content

Pac-Man


rush4hire
 Share

Recommended Posts

I wanted to wait till it's finished, to post about it, but I just can't wait.

It's so cute.

So.... I'm gonna start working on the ghosts now..

This is wearing me out cause.

1. Autoit is really not for making arcade games, but I want the challenge.

2. I don't have a source code for pac-man. I'm just thinking it out from scratch.

Here's a zip with the script and sound files and a compiled.

http://www.rush4hire.com/files/autoit_pacman.zip

Here's the home page: http://www.rush4hire.com/autoit_pacman/

Here are some screenshots:

The official icon: Posted Image

Game what I have so far: Posted Image

--- DAY 3 ---

It's comming along real well.

I have death, change of level (very dramatic), all the fruits, and I fixed the pac-man moving through walls bug.

Now I just need to focus on the ghost behavior, timing of fruits, high score system, and w/e else.

Posted Image

Here's the latest package with the same sound files:

http://www.rush4hire.com/autoit_pacman/aut...c-demo-1.02.zip

Here's the latest script by itself: packman.au3

It's rigged in this one for testing purposes.

It will be just like the origional 1979 game in gameplay.. But certain things will be better. Like the apple.. It will be green (there's too much red with the strawberry and cherrys)

Oh, ya and there will be a banana instead of grapes or w/e. I couldn't find grapes.. :whistle:

--- DAY 5 ---

The ghosts do everything they are supposed to do, but it's hard to test alot because the graphics cause so much lag. So I have to try this ProSpeed thing or something.

More comments in my next post.

I added some sound files so here's a new zip.

I got some background music, but the graphics cause lag. If you comment out these calls at the bottom like this:

While 1
    sleep($CURRENTSPEED)
    If $ISPAUSED Then ContinueLoop
    If Not $GB Then
        $GB = 1
        $GBOTTOM = Not $GBOTTOM
    Else
        $GB = 0
    EndIf
;   pacmove()
;   checkghosts()
;   checkdelays()
    playloop()
WEnd

And the only thing happening is playloop() then the sound timing is fine, but the lag causes the sound loop to pause.

Also I should give some instructions:

The arrow keys move pacman.

Space bar to pause.

Esc to exit.

You can drag the Window but you have to click in an area where there are no graphics.

If you pause it will unset the hotkeys. So when you want to unpause, just click the window again.

packman.au3.zip

autoit_pacman.zip

Edited by rush4hire
Link to comment
Share on other sites

Very very nice! Love the sounds :whistle:

Link to comment
Share on other sites

Ya, I was looking at ProSpeed today. It's very impressive.

But I have already been doing this with graphics functions, and not using image files. It looks like prospeed is mainly for messing with image files.

Now I can draw the ghosts' bodies in all the different colors, and make all the different eyes, with the 2 types of bottoms, 2 blue shades when they turn blue, and w/e else... but I'm not sure how organize it all in one or 2 x 3 demensional arrays..

I just can't stand redundancy, or I would be all done by now..

Link to comment
Share on other sites

ProSpeed is for Game sprites as well.. :D

Nice! I really want to try ProSpeed. I have to finish this first, then I might be able to use ProSpeed to optimize it.

Very nice! Although Pacman started acting weird at some point, it wouldn't "eat" the dots, and it went through walls :S

I know about that bug, but I will have to fix it when the whole thing is complete.

Worked GREAT for me. I seriously had fun, even without the ghosts.

Hehe. My gf likes it without ghosts :whistle:

Ok, I finally have all my ghost models! :P

Posted Image

Here's my tight code to produce 64 different ghosts (16*4)

Global Const $BLINKY = 0
Global Const $PINKY = 1
Global Const $INKEY = 2
Global Const $CLYDE = 3

Global Const $STATE_DEAD = 0
Global Const $STATE_BLUE = 1
Global Const $STATE_PINK = 2
Global Const $STATE_CHASE = 3

HotKeySet("{ESC}","_exit")
Opt("GUICloseOnESC",1)
Opt("GUIOnEventMode", 1)

;;;;;;;;;;graphics
Global Const $GUI_GR_CLOSE      = 1
Global Const $GUI_GR_LINE       = 2
Global Const $GUI_GR_BEZIER     = 4
Global Const $GUI_GR_MOVE       = 6
Global Const $GUI_GR_COLOR      = 8
Global Const $GUI_GR_RECT       = 10
Global Const $GUI_GR_ELLIPSE    = 12
Global Const $GUI_GR_PIE        = 14
Global Const $GUI_GR_DOT        = 16
Global Const $GUI_GR_PIXEL      = 18
Global Const $GUI_GR_HINT       = 20
Global Const $GUI_GR_REFRESH    = 22
Global Const $GUI_GR_PENSIZE    = 24
Global Const $GUI_GR_NOBKCOLOR  = -2

;; 0=x, 1=y, 2=state[ 0=dead, 1=blue, 2=normal, 3=chasing], 3=following a predefined path
Global $Ghosts[4][4] = [[109,114,0,0],[109,138,0,0],[93,138,0,0],[125,138,0,0]]
Global $Ghostb[4][3][6]; 64 ghost bodies. bleh
Global $GBOTTOM = 0; toggle bottom crap

;~ junk
Global $guiname = "testcrap ghosts"
Global $eyearr[5] = [fastarr(0,0,4,4,0), fastarr(2,1,3,1,0), fastarr(3,3,5,5,0), fastarr(2,4,3,7,0), fastarr(1,3,1,5,0)]
Global $bottomarr[3] = [StringSplit("2,6,7,11,1,2,3,6,7,10,11,12",","),StringSplit("4,9,0,3,4,5,8,9,10,13",","),StringSplit("2,3,6,7,10,11,1,4,5,8,9,12",",")]

;~ these r in teh other script
Func fastarr($a,$b,$c,$d,$e)
Local $temp[5]=[$a,$b,$c,$d,$e];    array functionality must be the biggest challenge when making a new language.
Return $temp
EndFunc
Func fastarr2($a,$B)
Local $temp[2]=[$a,$b]; array functionality must be the biggest challenge when making a new language.
Return $temp
EndFunc
Func Iif ($x,$y,$z)
If $x Then Return $y
Return $z
EndFunc


Func game_initialize()
Global $gui = GUICreate ( $guiname, 560, 160, -1, -1, 0x80000000+0x00800000 )
GUISetBkColor(0x000000)

;; bottoms x2 + no eyes
;; eyes x 4
;; no eyes
;; blue
;[2,5,3,7] ; funny shocked eyes

makeghosts()

Local $x = 25
Local $y = 25
for $ghost = $BLINKY to $CLYDE
;~ Global $Ghostb[4][3][6]; 64 ghost bodies. bleh

for $ii = 0 to 5
for $i = 0 to 2
    $id = $Ghostb[$ghost][$i][$ii]
    GUICtrlSetPos( $id, $x, $y)
    $x += 30
Next
Next
$y += 30
$x = 25
Next
GUISetState()
EndFunc
game_initialize()


Func makeghosts()
Local $colors[4] = [ 0xFF0000, 0xFFB8DE, 0x00FFDE, 0xFFB847 ]
Local $blues[4] = [ 0x3333CC, 0xFFFFFF, 0xFFEEEE, 0xFF0000 ]
For $ghost = $BLINKY to $CLYDE
;;; 4 ghosts
For $i = 1 to 4;  4 eye positions
$ids = makebody($colors[$ghost])
    For $ii = 0 to 1 ; 2 bottom wiggly things..
        $Ghostb[$ghost][$ii][$i] = $ids[$ii]
        makeeyes( $ids[$ii], $i )
    Next
$id = GUICtrlCreateGraphic(0, -50, 14, 14);         make eyes w no body
makeeyes ($id, $i)
$Ghostb[$ghost][2][$i] = $id
Next
;blue edible ghosts. blue / 
For $i = 0 to 1; - 2 shades
    $ids = makebody( $blues[$i] )
    For $ii = 0 to 1; 2 bottoms
    makeeyes( $ids[$ii], 0, $blues[$i+2] )
    $Ghostb[$ghost][$ii][$i*5] = $ids[$ii]
    Next
Next
Next
EndFunc


Func makebody( $color )
Local $arr[2]
for $i = 0 to 1
$arr[$i] = GUICtrlCreateGraphic(0, -50, 14, 14)
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, $color,$color)
GUICtrlSetGraphic(-1,$GUI_GR_ELLIPSE, 0,0, 14, 15)
GUICtrlSetGraphic(-1,$GUI_GR_RECT, 0,10, 14, 4)
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000, 0x000000)
GUICtrlSetGraphic(-1,18, 0, 5)
GUICtrlSetGraphic(-1,18, 13, 5)
GUICtrlSetGraphic(-1,$GUI_GR_RECT, 5, 14, 4, 1)
makebottom($arr[$i], $i)
Next
Return $arr
EndFunc


Func makeeyes($id, $type, $color = 0x2121DE)
$a = $eyearr[$type]
If $type Then
    $b = 6
GUICtrlSetGraphic($id, $GUI_GR_COLOR, 0xDEDEDE, 0xDEDEDE)
GUICtrlSetGraphic($id, $GUI_GR_ELLIPSE, $a[0], $a[1], 4, 5)
GUICtrlSetGraphic($id, $GUI_GR_ELLIPSE, $a[0]+$b, $a[1], 4, 5)
GUICtrlSetGraphic($id, $GUI_GR_COLOR, $color, $color)
Else
    $b = 4
    makebottom($id, 2, $color)
EndIf;0xFFCC99
GUICtrlSetGraphic($id,$GUI_GR_COLOR, $color, $color)
GUICtrlSetGraphic($id,$GUI_GR_ELLIPSE, $a[2], $a[3], 2, 2)
GUICtrlSetGraphic($id,$GUI_GR_ELLIPSE, $a[2]+$b, $a[3], 2, 2)
EndFunc

Func makebottom($id, $type, $color = 0x000000)
$a = $bottomarr[$type]
$y = Iif ($type == 2, 8, 12)
GUICtrlSetGraphic($id,$GUI_GR_COLOR, $color, $color)
For $i = 1 to $a[0]
    If $a[$i] < 2 Then $y += 1
    GUICtrlSetGraphic( $id, 18, $a[$i], $y)
Next
EndFunc

while 1
    sleep(50)   
WEnd
Func _exit()
    Exit
EndFunc

I'm sure there's not a more efficient way to make and manage all these ghost models.

One time I got a shocked looking ghost by accident, and I'm thinking about using this when the ghost kills Pac-Man.. Like he's saying "Wow. I can't believe I got him!! I win.. gg!" Posted Image

Link to comment
Share on other sites

Wow... This amazes me so much. Not using one single image... Just wow. I now realize how much Autoit can do at it's full potential.

While reading the above comment, think of some dramatic adventure music. That is what i was thinking when i typed that.

Link to comment
Share on other sites

I made some good progress today. I was really stuck on the pac-man moving bug. It was so simple it baffled me. :whistle:

I updated my first post.

This script I posted is super fast. I started with a refresh rate of every 70 ms and kept going faster. I felt 40 ms was pretty good. But I decided to try 10 ms for kicks and I'm surprised at the performance.

But I don't know how it will work when the ghosts will be moving all over.

And if you go to 5 ms it seems to be almost the same as 10 ms..

Maybe if someone wants to train to be a professional pac-man player, he can use this in fast mode. lol.. :D

Hey, I'm into it. I got #4 high score in the dota-allstars.com arcade :P

[note]

If you want to see the levels change real fast for a demo, change this"

Global $LEVEL_DEMO_MODE = FalseoÝ÷ ÚÚºÚ"µÍÛØ[ ÌÍÓUSÑSS×ÓSÑHHY

-- oh ya --

You can also change this:

Global $ANIMODE = False

to True

And you will see the the map being made.

Edited by rush4hire
Link to comment
Share on other sites

Thanks. I can live without grapes. But it would be nice to have more sounds.

So this book you have explains the patterns of the ghosts ? Not how it's coded, but their behavior? Like if you get within a certain range of a ghost he starts following you, and like if you eat a certain number of dots the ghosts start moving faster and that number decreases with each level? What is that number? And how much faster do the ghosts move each level?

I know how long they stay blue decreases with each level, but I have no idea how much.

But more than these things I need the background music. And the music when it gets faster, and the music when it's time to eat ghosts...

I got sounds from here http://pac-man.classicgaming.gamespy.com/Sounds/

I got pics from wikipedia and http://www.iconarchive.com/icon/game/arcad...ence/index.html

Link to comment
Share on other sites

Everything works great now as far as I can tell.

The ghosts are insane! But laggy... :whistle:

Of course I have a TODO list. Here it is:

;TODO

;fix graphic laggg

;fix fruit behavior

;fix occasional ghost leaving the screen

;find a better way for ghosts to chase pacman (can be complex)

;Opening page / scene and intermission cinimatics

;Game Over cinimatic

;high score system

;one of those right click menus

Should be easy.

Now I'm checking out ProSpeed.

Link to comment
Share on other sites

Everything works great now as far as I can tell.

The ghosts are insane! But laggy... :whistle:

Of course I have a TODO list. Here it is:

;TODO

;fix graphic laggg

;fix fruit behavior

;fix occasional ghost leaving the screen

;find a better way for ghosts to chase pacman (can be complex)

;Opening page / scene and intermission cinimatics

;Game Over cinimatic

;high score system

;one of those right click menus

Should be easy.

Now I'm checking out ProSpeed.

i'm lost where is the latest version?

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

I also updated the first post here.

But the ugly home page should also have the latest.

It's ok, but like I just said, it's so laggy.

It seems all the time to make everything with graphics functions was a waste if I have to use something like ProSpeed.dll because it uses image files only.

But it's cool. I'm glad I discovered ProSpeed. This gives me hope that I can make some other games too.

I want to program in flash, but it's too expensive for me.

Link to comment
Share on other sites

Good luck with making a Pacman version with ProSpeed, I`m still working on my (almost complete now) breakout game, but the level indecator I`ve added has introduced a bug with the display of the bricks after level 15, so I need to fix that now...

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

Of course there will be a few bugs. It's brand new. But that red ghost comes back at the next level.

It's pretty good for how much time has gone into it. How much time did it take to develope the origional pac-man in the 70s? And how much code? I'm sure it was much more redundant than this script. It's less than 1200 lines and 35 kb!

But my main thing now is to redo the whole thing by using prospeed.dll somehow.. Then I will fix those bugs and do the other things.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...