Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Converting ScouseKinght's Pacman Tutorial to 2d?

Author
Message
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 14th Apr 2004 17:36
Ive been trying to convert ScouseKnight's pacman tutorial to 2d. I got the pacman moving and the maze drawn and everything until it came to checking whether the walls were solid. Then my pacman stopped moving. The code is attached here and at the bottom.



Any help would be greatly apreciated,

Michael

Ps my tiles are 16 * 16 just incase anyone wanted to know


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 14th Apr 2004 17:46
try this

do
oldx=x
oldy=y

if sprite collision(pac-man,walls)>0
x=oldx
y=oldy

sprite 1,x,y,1
endif
loop

That what I made in my Pac-Man game theat i'm making.

CURRENT PROJECT: RETRO PAC-MAN
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 14th Apr 2004 20:50
That doesnt really fitin with the tutorilaimdoing but thanks anyway. I'd really apreciate some help on this.

Cheers,

Michael


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Scouseknight
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 14th Apr 2004 23:05
Check that the player starts in a coordinate that is the centre of a cell - this is usually the cause of this sort of problem - the player is not in the centre of a cell to begin with and none of the directions allowed are triggered hence it won't budge.

Secondly, I seem to recall having to add 1 to X and Y coordinate worked out as well in my own 2D version of the game.

If your still having problems after this I'll have a more thorough look at it - I won't have time this evening sadly (I'm on a 6am start for a few weeks at work).

Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 15th Apr 2004 00:43
Thanks for your help. I'll try that now.


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 15th Apr 2004 12:14
I tried what you said Scouseknight and it still didnt work. If anyonecan see any problems with the code their help would be greatly apreciated.

Cheers,

Michael


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Scouseknight
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 15th Apr 2004 12:30
If nobody has replied by the time I have finished work I will have a good look.

Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 15th Apr 2004 17:00
Thanks ScouseKnight!


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Scouseknight
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 15th Apr 2004 17:38
OK Michael - I think we have this cracked now.

The first problem was the player's X and Y coordinates were not converting back to maze array elements - the reason for this was the maze was drawn in the center of the screen which meant a larger adjustment was needed to the playerx# and playery# values before dividing them by 16 :



Now, the player's start position in terms of array cells is 17 down by 9 across which is spot on - and the player is also dead center of this cell now too - which means center = 1 will be true and we can kick off moving our player.

The next thing was the code to construct the maze - the values of X and Y were being used in the for..next loop - but mazex and mazey were being used to populate the array - this meant the maze# array was filled with zeros hence no movement was possible - I also added 1 to the X and Y because the maze loop was 0 to 19, and 0 to 15 respectively - the elements would be 1 to 20 and 1 to 16 - the new code is here :



The other things were just minor easy-to-make errors - the basic concept of what you wanted was there!

playercangonright=0 should have read playercangoright=0 - the effect of this is once the player have moved right he will always be able to move right because that value was never being set to 0.

if mazdown = 0 should have read if mazedown=0.

Finally, the mazeup and mazedown had + 1 for mazeup and - 1 for mazedown - it should have been the other way around.

The full correct code is as follows :



Like I said though don't be too bothered about any of that - the concept was right - the conversion from the 3D to 2D was there and would have worked - I'm always having to go back and correct things I do!!

Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 15th Apr 2004 18:25
Thats brilliant Scouseknight. I can't thankyou enough.

Cheers,

michael

PS. Great tutorial by the way. I just wish the mods would sticky it.


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Scouseknight
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 15th Apr 2004 19:49
Cheers Michael glad you found it useful

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 16th Apr 2004 03:39 Edited at: 16th Apr 2004 03:45
bling stuckified!

now help me find the 3d tutorial link and ill make that sticky as well


fall down seven times, stand up eight
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 16th Apr 2004 21:44
Heres a link to the tutorial thread.
No poing having two stickies for the same tut.

http://www.thegamecreators.com/?m=forum_view&t=28865&b=7

you ain't the cops
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 16th Apr 2004 22:04
Nope


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 17th Apr 2004 01:51
I have another question. Is it possible touse the sprite collision commands in DBPro to make pacmaneat thepills. I wanted to use thesprite command so it returned the number of the sprite that it collided with and stored it in a variable. If this number was oneof the pills then it would delete that sprite. This is how i think it should be done but it doesnt work. (this is not the actual code i tried)



If anybody knoshow to implement that into DBP then their help would be greatly apreciated.

Cheers,

Michael


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 17th Apr 2004 04:19
I made this in my Pac-Man game that I'm making


for pillsate=start pill to the last number of pills(the sprite no.)
if sprite collision(pac-man,pillsate)>0 then hide sprite pillsate
next pillsate


I hope that helps

CURRENT PROJECT: RETRO PAC-MAN
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 17th Apr 2004 14:22
Thanks for your help commando 300. Thats exactly what i meant but all it does it produce an error saying that that sprite doesn't exist. My pill numbers start from 200 and i have 143 pills. So i used this code:



My full source code is at the bottom. Cheers,

Michael


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 17th Apr 2004 20:49
is the same thing I told you

But I'm glad I help you

CURRENT PROJECT: RETRO PAC-MAN
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 17th Apr 2004 20:51 Edited at: 17th Apr 2004 20:52
Yes i know thats the code you told me. What i was saying was that it didn't work, it just produced the sprite doesnt exist error, even when i substituted in the orrect values and variable names. I still havnt got it working yet.


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 18th Apr 2004 01:12
I've found the problem. I was using pacmans image number instead of his sprite number.

Thanks for your help commando 300 with the code sample. I tried using the built in sprite collision commands but they arn't that brilliant so i decided to use the pixel perfect collision example in the codebase. Thanks evryone for all their help.

Cheers,

Michael


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Scouseknight
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 18th Apr 2004 01:48
Is that the one by Freddix incidentally?

I am using that in my current project - really is the dog's nads is that function

Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 18th Apr 2004 01:52
The function i am using is made by IanM. Nice function if your reading. lol.

Cheers,

Michael


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Scouseknight
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 18th Apr 2004 02:04
Cheers Michael I'll have a look at that one - although Freddix's one is doing a good job in my game I'll probably stick with it this time.

Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 19th Apr 2004 23:27
Just posting some progress. I've been working on the ghost over the weekend and tonight. I finished all the code in the tutorial about the ghost movement and AI however there is a problem somewhere inmy code. I have spent ages lookingfor itbuti can't seem to find it. Sometimes the ghosts stop completely andother times they manage to move diagonaly throught the walls of a junction. The Ai doesnt seem to be working either as the ghosts pay no attentionto the player whatsoever. If anyone couldhavea quicklook throughmy codethen i'd be really grateful.

Cheers,

Michael




Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 20th Apr 2004 01:30
*off topic*

Just a little question, how many points do you gain for each pill pac-man eat?

CURRENT PROJECT: RETRO PAC-MAN
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 20th Apr 2004 01:43
I set them to 10 im my game. I'd also be interested to know the correct amount for ghosts, fruit, powerpills etc.


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Scouseknight
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 20th Apr 2004 01:50
I think Ghosts are 100 for the first, 200 for the second, 400 for the third and 800 for the fourth if you get them all before the power pill runs out - that's what I tend to do anyhow.

I'll have a shuftie at the code when I get time probably tomorrow - in the meantime, perhaps some kind soul can help.

comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 20th Apr 2004 01:53
thanks!

CURRENT PROJECT: RETRO PAC-MAN
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 20th Apr 2004 21:19
That'd be great. thanks.


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 21st Apr 2004 19:26
Have you had chance to have a look through the code anyone?


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Scouseknight
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 21st Apr 2004 20:57
Michael any chance you could zip what you have up and e-mail it along to me so I can have all the media to work with e.t.c.?

Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 21st Apr 2004 21:38
I've sent the email now. Thanks for your help. BTW it's a.rar file. Can you open these? If not just give us a shout.

Cheers,

Michael


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Scouseknight
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 21st Apr 2004 21:46
Aye I can open rar files no bother - I'll take a look as soon as I can - sorry for delays!

Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 21st Apr 2004 22:08
Thats fine. Thanks for your help.


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 21st Apr 2004 23:34
Sorry Scouseknight it hasn't sent. You can download it here at http://codemonkeydownloads.dbspot.com/Pacman.rar


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Scouseknight
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 22nd Apr 2004 00:36
Michael the reason the ghosts are moving diagonally and sticking sometimes is that on occasions, more than one direction is set to 1.

I amended the code after the ghostturn function was called :



And also amended the code that checks for the player position :



Although this did stop the diagonals and stuck ghosts - the ghosts were doubling back on themselves all the time - the turorial game also had this problem and did address it - my head is chocker at the moment (these 5am starts at work are killing me!!) - see if you can get to the bottom of it - if not, I will have a look tomorrow evening when I am fresher.

Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 22nd Apr 2004 01:03
Thanks for your help Scouseknight. I'll re-read the tutorial on that bit now.


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
Scouseknight
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 22nd Apr 2004 01:34
I'm sure you'll sort it - you've done a marvellous job of coverting the 3D to 2D so far - I might hold back on my 2D Pac Man tutorial now and let you do it Seriously..

comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 22nd Apr 2004 02:32 Edited at: 22nd Apr 2004 02:33
I have to tell you something Code Monkey, the function to know which pill was ate will not work if u are going to make the score, I discovered by myself, use offset sprite instead of hide sprite

CURRENT PROJECT: RETRO PAC-MAN
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 22nd Apr 2004 19:39 Edited at: 22nd Apr 2004 19:40
@ commando 300: Why won't it work. I have it working. All you have to do is declare the score value as a global variable.

@ Scouseknight: Were you serious. I'd be glad to do it.


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 22nd Apr 2004 20:51
oh! This tutorial is for DBPro I'm using DBC Enhanted and I can't set the variables as global

CURRENT PROJECT: RETRO PAC-MAN
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 22nd Apr 2004 20:56
Ah. That would be why.


Visit the Code Monkey's website at http://www.freewebs.com/codemonkeystudios

Login to post a reply

Server time is: 2024-11-26 14:44:59
Your offset time is: 2024-11-26 14:44:59