Computer Science Canada

Insectoid's PacMan blog

Author:  Insectoid [ Thu May 08, 2008 8:17 am ]
Post subject:  Insectoid's PacMan blog

So, I decided to start a blog on my work on PacMan. I am expecting 1-2 weeks more work. I will update frequently (usually daily) and ask for help in this post.

Completed to date:

-All images
-Movement
-collision detection
-'Automated coin drawing procedure'
-The Cherry
-Mouth open/close animation
-Points system

Need to do:

-All sounds- If someone has unpolluted pacman sounds, could you post them?
-Ghost AI- Going to need help with this
-Intro/Game over screens
-Ghost 'Oh no! you can eat me now!"
-High Scores
-Adjust movement to pac-man style (never stops)
-'pacman dead' animation

UPDATE: I got some basic AI working now, but there is so much for the computer to check that it is EXTREMELY laggy!
I have it
-Checking for coin collision
-Checking for cherry collision
-Checking for wall collision
-Checking for Ghost wall collision
-Checking for ghost AI
-Checking for mouth open/close
Here are the things I HAVEN'T done yet and need to do!

-Checking for pacman/ghost collision
-Checking for banana colision (instantly makes the ghosts edible)
-Checking for edible ghost collision

Does it have something to do with me checking with whatdotcolor for everything except sprite-on-sprite action?

Help?

Author:  Michael516 [ Fri May 09, 2008 7:36 am ]
Post subject:  RE:Insectoid\'s PacMan blog

this is a neat game, but there is one problem, there is just barely enough room for him to fit through so I get stuck on corners a lot.

Author:  nastynika [ Fri May 09, 2008 8:03 am ]
Post subject:  Re: Insectoid's PacMan blog

nice job so far i will try to make so adjustments for u and repost it so u can continue adding on to it

Author:  Insectoid [ Fri May 09, 2008 10:10 am ]
Post subject:  Re: Insectoid's PacMan blog

Update! I finished putting in a bunch of sounds, though I need a new background one (The one I have sounds like crap)

Also, it tells you how many coins are left (rouph version) and there are 'win' and 'lose' procedures. But as you can only win thus far, you will never get to see the 'lose' proc unless you take it out and test it on its own.

Enjoy!

EDIT: I put in a countdown timer that gives you 2000 seconds to get all the coins (well, 200 seconds because of lag) , so now you can lose and win! If you win, it seems you have to click on another window before it will give you the rough draft of my 'you win!' screen.

Once again, Enjoy!

Author:  Insectoid [ Mon May 12, 2008 4:48 pm ]
Post subject:  Re: Insectoid's PacMan blog

Update!
I got the rediculously simple AI back in, but there is a problem. It only shows a blank screen, until you terminate the program.
Thus, I have not been able to see if it works. In theory, it should. Pathfinding seems like a cool thing to boost my marks, and I notice there is no tutorial on it (Unless it's hiding from me, they do that sometimes...)

If someone has an example of pathfinding AI, could you show me, so that I can stop hating myself for not knowing?

I realized while working that my pacman death animation BooHoo only works if your pointing in a certain direction (left). This is a stupid mistake to be fixed once I feel like it (once all the cool bits are out of the way)

Just out of curiosity, what is the bits system for? What can you do with bits? Are they for bragging rights?

Anyway, Here's the newest edition of PacMan- Jordan style

EDIT: I noticed I forgot a line of code in the AI procedure (Sprite.Animate) and so that's fixed. Still have some trouble with the whole 'blank screen thing'. I also cleaned up my code a bit, so you can read it better.

New problem: 'Sprite was freed'. I didn't free it myself, must be an automatic feature in turing. Could someone explain this?
New feature: The one ghost I have in the game now will occasionally turn dark blue, meaning he's edible. This has no impact on the game (YET!) so if you run into him (after you fix the bugs I don't know how to fix) nothing will happen. This will be done soon...

Author:  Insectoid [ Mon May 12, 2008 8:57 pm ]
Post subject:  Re: Insectoid's PacMan blog

Okay, I've been working on the high scores right now.

This here is my code for putting the new high score in the right place. I'm sure there is a better way that doesn't use 100 lines, but that is beyond my current knowledge.

Turing:

%High scores

var newhighscore : int := 3700
var newname : string := "This works!"
var scorelist : int

type highscore :
    record
        name : string
        score : int
    end record

var highscores2 : array 1 .. 10 of highscore

open : scorelist, "Scorelist.in", get

for collect : 1 .. 10
    get : scorelist, highscores2 (collect).score
    get : scorelist, highscores2 (collect).name
end for

if newhighscore > highscores2 (1).score then
    highscores2 (10) := highscores2 (9)
    highscores2 (9) := highscores2 (8)
    highscores2 (8) := highscores2 (7)
    highscores2 (7) := highscores2 (6)
    highscores2 (6) := highscores2 (5)
    highscores2 (5) := highscores2 (4)
    highscores2 (4) := highscores2 (3)
    highscores2 (3) := highscores2 (2)
    highscores2 (2) := highscores2 (1)
    highscores2 (1).score := newhighscore
    highscores2 (1).name := newname

elsif newhighscore > highscores2 (2).score then
    highscores2 (9) := highscores2 (8)
    highscores2 (8) := highscores2 (7)
    highscores2 (7) := highscores2 (6)
    highscores2 (6) := highscores2 (5)
    highscores2 (5) := highscores2 (4)
    highscores2 (4) := highscores2 (3)
    highscores2 (3) := highscores2 (2)
    highscores2 (2).score := newhighscore
    highscores2 (2).name := newname

elsif newhighscore > highscores2 (3).score then
    highscores2 (8) := highscores2 (7)
    highscores2 (7) := highscores2 (6)
    highscores2 (6) := highscores2 (5)
    highscores2 (5) := highscores2 (4)
    highscores2 (4) := highscores2 (3)
    highscores2 (3).score := newhighscore
    highscores2 (3).name := newname

elsif newhighscore > highscores2 (4).score then
    highscores2 (7) := highscores2 (6)
    highscores2 (6) := highscores2 (5)
    highscores2 (5) := highscores2 (4)
    highscores2 (4).score := newhighscore
    highscores2 (4).name := newname

elsif newhighscore > highscores2 (5).score then
    highscores2 (6) := highscores2 (5)
    highscores2 (5).score := newhighscore
    highscores2 (5).name := newname

elsif newhighscore > highscores2 (6).score then
    highscores2 (10) := highscores2 (9)
    highscores2 (9) := highscores2 (8)
    highscores2 (8) := highscores2 (7)
    highscores2 (7) := highscores2 (6)
    highscores2 (6).score := newhighscore
    highscores2 (6).name := newname

elsif newhighscore > highscores2 (7).score then
    highscores2 (10) := highscores2 (9)
    highscores2 (9) := highscores2 (8)
    highscores2 (8) := highscores2 (7)
    highscores2 (7).score := newhighscore
    highscores2 (7).name := newname

elsif newhighscore > highscores2 (8).score then
    highscores2 (10) := highscores2 (9)
    highscores2 (9) := highscores2 (8)
    highscores2 (8).score := newhighscore
    highscores2 (8).name := newname

elsif newhighscore > highscores2 (9).score then
    highscores2 (10) := highscores2 (9)
    highscores2 (9).score := newhighscore
    highscores2 (9).name := newname

elsif newhighscore > highscores2 (10).score then
    highscores2 (10).name := newname
    highscores2 (10).score := newhighscore
end if


for x : 1 .. 10
    put highscores2 (x).name : 20, highscores2 (x).score
end for


And here is my base list with scores to beat


Scorelist.in
code:

6000         "Clyde"
5500         "Blinky"
5000         "Inky"
4500         "Pinky"
0000         "NONE"
0000         "NONE"
0000         "NONE"
0000         "NONE"
0000         "NONE"
0000         "NONE"


My main question is, how can I import this into my main program (see previous post) and change Scorelist.in to reflect the new list as created by the huge 100 line code (highscores.t)

Author:  syntax_error [ Mon May 12, 2008 11:13 pm ]
Post subject:  Re: Insectoid's PacMan blog

use for loops to loop through the array indices and to replace values, much less lines of code.

Author:  Insectoid [ Tue May 13, 2008 8:03 am ]
Post subject:  RE:Insectoid\'s PacMan blog

Well, I tried a for loop, and it doesn't work. I get the message 'array subscript is out of range". No you're probably reading this and saying 'holy crap this guy is dumb' but I am only in gr. 10, we have not done arrays yet, and we will not be doing records, so you can see, this is very new to me.

Turing:

var newhighscore : int := 6500
var newname : string := "PacMan"
var scorelist : int


type namesandscores :
    record
        name : string
        score : int
    end record

var highscores : array 1 .. 10 of namesandscores

open : scorelist, "scorelist.in", get


for sort : 1 .. 10
    get : scorelist, highscores (sort).score
    get : scorelist, highscores (sort).name
   
    if newhighscore > highscores (sort).score then
        newhighscore := highscores (sort).score
        newname := highscores (sort).name
    end if
   
    highscores (sort) := highscores (sort + 1)


end for

for display : 1 .. 10
    put highscores (display).name : 20, highscores (display).score
end for


Still wondering how to replace names & numbers in 'scorelist.in'. Help?

Author:  Insectoid [ Tue May 13, 2008 6:41 pm ]
Post subject:  RE:Insectoid\'s PacMan blog

I got all the ghost collisions done, but I'm not going to post them as it is such a small update. My progress is going very slow as the whole 'not displaying anything' bug still hasn't been fixed...or the 'sprite was freed' bug. I noticed that when I put the sprite declarations into the procedure, that did not happen. Of course, that way I reach the max number of sprites (1000) in a second.

Help is still apreciated.

Author:  Insectoid [ Thu May 15, 2008 6:27 pm ]
Post subject:  RE:Insectoid\'s PacMan blog

No more updates until the problems are fixed.

Author:  Insectoid [ Sat May 17, 2008 8:21 pm ]
Post subject:  Re: Insectoid's PacMan blog

Yes, I know, I said no more update!s, but I couldn't resist!

I have added in a menu and a pre-game animation. For some reason if flickers, but I have set it to offscreenonly and used View.Update.

Looking back at my original post in this thread, I find that all I have left to do is the high scores, movement adjustment, and fix the 'you're dead' bit! That and fix the 2 bugs in the game...
even If I get a grade of 300% on this project, I will still not be happy unless that second glitch (The 'sprite was freed' glitch) is fixed (The other seems to have repaired itself with the menu)

So, Here is my current version of PacMan!

EDIT: I put in some extra sounds (for the menu) and slowed down the animation so it is as long as the intro song. Also changed the intro from WAV to MP3 so that it doesn't cut out when you select something from the menu.

Author:  death bringer [ Fri May 30, 2008 9:17 am ]
Post subject:  RE:Insectoid\'s PacMan blog

It's an ok game but you really need to work on the computers AI becasue once they start casesing you they dont sto. also the postion of the dots isn't the best maybe try aligning them more. lastly play the original pacman and try to add thing like the fruit and attempt to make the ghost blink once or twice before they stop runing away from you. lastly if you want to go all out add music to the background using maybe

process BackgroundMusic
loop
play ("")
end loop
end BackgroundMusic

Author:  Insectoid [ Sat May 31, 2008 8:43 am ]
Post subject:  RE:Insectoid\'s PacMan blog

I had that, but it got annoying so I turned it off. I have played the original pacman many times to try and get this one right. I assume you downloaded the first one? And it worked? The ghosts actually worked? what did you do to fix it?

The positioning of the dots is perfect, actually, which you may have noticed if you downloaded the newest version.

There are fruit, if you didn't notice. it gives you 100 points. The 'ghost get sick' fruit is actually a large coin, maybe you should try playing the original pacman.


Have you read the entire thread yet? That would be usefull, as right now, your post is considered spam (<a href="http://en.wikipedia.org/wiki/Spam_(electronic)">http://en.wikipedia.org/wiki/Spam_(electronic)</a>)

EDIT
- seems the url won't work...

edit: fixed url with html text instead of bbcode Wink

Author:  TheWanderer [ Sat May 31, 2008 11:41 am ]
Post subject:  Re: RE:Insectoid\'s PacMan blog

insectoid @ Tue May 13, 2008 8:03 am wrote:
Still wondering how to replace names & numbers in 'scorelist.in'. Help?


This looks a lot like the sorting I used for my FP game.

to update the score text file I read them off the file, and into the array like you did,
then immediately close the file ID.

in your case,
close : scorelist

now Turing is not accessing that file.

after sorting it with your game scores,
open that file again with a new int ID, and then write your new array back into it,
then close it a second time

works for me.

btw please check my game for an example of score sorting, thanks!

Author:  Insectoid [ Sat May 31, 2008 2:02 pm ]
Post subject:  RE:Insectoid\'s PacMan blog

so if I write back into it that way, it will erase the contents and put in the new stuff? That's what I'm after (Or just replacing...)

Author:  TheWanderer [ Sat May 31, 2008 2:57 pm ]
Post subject:  Re: RE:Insectoid\'s PacMan blog

insectoid @ Sat May 31, 2008 2:02 pm wrote:
so if I write back into it that way, it will erase the contents and put in the new stuff? That's what I'm after (Or just replacing...)


In short, yes.

Reason: when you open a file with

Turing:
open : filestreamnumber, filename, put


I believe it opens the file with a clean slate (blank file). the key is the "put" at the end of the line

so when you output your edited score array, it should serve the purpose.

remember to close the file the first time after you read it.
so Turing doesn't recognize it, but puts it into memory as a new file to write to.

Author:  Insectoid [ Sun Jun 01, 2008 1:31 pm ]
Post subject:  RE:Insectoid\'s PacMan blog

Oh, well that's useful! Could also be a pain in other projects involving large files and huge amounts of data (But who's going to use turing for something like that?).

Now I just need to do a sorting algorithm (not to hard) and fix the one d*amn bug and presto! finished! A++ on my final project! (Everyone else is doing a slot machine, which I am also doing for computer engineering).

Author:  Insectoid [ Wed Jun 04, 2008 10:00 am ]
Post subject:  RE:Insectoid\'s PacMan blog

Right, I REALLY need the bug to be fixed. The project has been assigned now, which means I haven't got much time left (less than 10 school days left in the year...). So if ANYONE has a solution, PLEASE, TELL!

note- the bug is the whole 'sprtie was freed' thing)


: