Jump to content



1

Maze example program with Pac-Man style sprite


26 replies to this topic

#1 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,923 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sun Jul 31, 2011 7:40 PM

After finding a better way to do things in the code of the 23 x 24 version of this, I came back and fixed the code in this 32 x 12 version. I often copy and paste REMs and I discovered some places where I forgot to change the text, so those places have been fixed too.


Latest Version

Here's the .bin file to use with an emulator or Harmony cart:

Attached File  ex_maze_32x12_2011y_08m_02d_1337t.bin   16K   49 downloads


Here's the bB code:

Attached File  ex_maze_32x12_2011y_08m_02d_1337t.bas   43.06K   36 downloads


ex_maze_32x12_2011y_08m_02d_1337t.png




----------------------------------------------




Original Post

Below is the first draft of a maze example program that I'm working on for the bB page. You can move the Pac-Man style sprite around and you'll also see an enemy sprite that randomly moves around the maze. I didn't give the enemy any brains in this example program. It's stupid and can't hurt you at this time.

This started out as a 32 x 24 maze, but the scanline count kept going over 262 since there was a lot more pfread use. I had to drop back down to ugly town (32 x 12) for this example.

If anyone who is great at math wants to look at my code and make it better, please do so. There are probably a lot of ways to improve the code, so feel free to fix it up and post it here.


Here's the .bin file to use with an emulator or Harmony cart:

Attached File  ex_maze_2011y_07m_31d_2108t.bin   16K   56 downloads


Here's the bB code:

Attached File  ex_maze_2011y_07m_31d_2108t.bas   42.76K   55 downloads

Edited by Random Terrain, Sat Aug 6, 2011 9:15 PM.


#2 Jr. Pac OFFLINE  

Jr. Pac

    Dragonstomper

  • 775 posts
  • 1/4 of the fun with an Atari cart is cleaning it.
  • Location:In my room with my 2600.

Posted Sun Jul 31, 2011 7:46 PM

Thank you so much!!!

#3 jrok OFFLINE  

jrok

    Stargunner

  • 1,108 posts

Posted Sun Jul 31, 2011 8:03 PM

Hey RT, I haven't taken a look at your code yet, but I know I did a 32x24 pf-avoidance routine for Circus Galacticus. If I recall correctly, I wound up doing most of the sprite coord-to-pf coord and case conditions during vblank to get the timing right. You might want to try stuffing some of the math into a vblank routine to cut down on cycle use.

#4 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,923 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sun Jul 31, 2011 8:06 PM

View Postjrok, on Sun Jul 31, 2011 8:03 PM, said:

Hey RT, I haven't taken a look at your code yet, but I know I did a 32x24 pf-avoidance routine for Circus Galacticus. If I recall correctly, I wound up doing most of the sprite coord-to-pf coord and case conditions during vblank to get the timing right. You might want to try stuffing some of the math into a vblank routine to cut down on cycle use.
I totally forgot about that! :dunce:

It sure would be nice if I could go back up to 32 x 24. I'll try it tomorrow and see what happens.


Thanks!

#5 Jr. Pac OFFLINE  

Jr. Pac

    Dragonstomper

  • 775 posts
  • 1/4 of the fun with an Atari cart is cleaning it.
  • Location:In my room with my 2600.

Posted Sun Jul 31, 2011 8:18 PM

Ugh! Another syntax error! How do I fix this one?

Attached Files



#6 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,923 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sun Jul 31, 2011 8:39 PM

View PostJr. Pac, on Sun Jul 31, 2011 8:18 PM, said:

Ugh! Another syntax error! How do I fix this one?
I just tried it and don't get an error.

#7 Jr. Pac OFFLINE  

Jr. Pac

    Dragonstomper

  • 775 posts
  • 1/4 of the fun with an Atari cart is cleaning it.
  • Location:In my room with my 2600.

Posted Sun Jul 31, 2011 10:20 PM

I keep getting a syntax error! :(

#8 ScumSoft OFFLINE  

ScumSoft

    Moonsweeper

  • 331 posts
  • Location:Polysorbate 60

Posted Sun Jul 31, 2011 10:29 PM

View PostJr. Pac, on Sun Jul 31, 2011 10:20 PM, said:

I keep getting a syntax error! :(
Got your compiler setup properly?

#9 Jr. Pac OFFLINE  

Jr. Pac

    Dragonstomper

  • 775 posts
  • 1/4 of the fun with an Atari cart is cleaning it.
  • Location:In my room with my 2600.

Posted Sun Jul 31, 2011 10:33 PM

Yes... :? I'll try again.

#10 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,923 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sun Jul 31, 2011 10:34 PM

View PostJr. Pac, on Sun Jul 31, 2011 10:20 PM, said:

I keep getting a syntax error! :(
Are you using the bBWin7_64bit.zip file mentioned here:

http://www.randomter...#gettingstarted

#11 Jr. Pac OFFLINE  

Jr. Pac

    Dragonstomper

  • 775 posts
  • 1/4 of the fun with an Atari cart is cleaning it.
  • Location:In my room with my 2600.

Posted Sun Jul 31, 2011 10:38 PM

I had to redownload bB and now it works....

#12 Jr. Pac OFFLINE  

Jr. Pac

    Dragonstomper

  • 775 posts
  • 1/4 of the fun with an Atari cart is cleaning it.
  • Location:In my room with my 2600.

Posted Sun Jul 31, 2011 11:13 PM

Can you please make one with dots worth 10 points each? That would be great!

#13 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,923 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sun Jul 31, 2011 11:23 PM

View PostJr. Pac, on Sun Jul 31, 2011 11:13 PM, said:

Can you please make one with dots worth 10 points each? That would be great!
Unless some code genius makes a special kernel or minikernel for bB that can create a bunch of dots out of a ball or a missile, it's not going to happen. We have two sprites, playfield pixels, a ball, and two missiles (but usually only one missile or no missiles depending on the kernel_options used).

Edited by Random Terrain, Sun Jul 31, 2011 11:23 PM.


#14 jrok OFFLINE  

jrok

    Stargunner

  • 1,108 posts

Posted Mon Aug 1, 2011 12:19 AM

View PostJr. Pac, on Sun Jul 31, 2011 11:13 PM, said:

Can you please make one with dots worth 10 points each? That would be great!

Why don't you make one with dots worth 10 points each?

Or is RT supposed to write "your" game? :ponder:

#15 Jr. Pac OFFLINE  

Jr. Pac

    Dragonstomper

  • 775 posts
  • 1/4 of the fun with an Atari cart is cleaning it.
  • Location:In my room with my 2600.

Posted Mon Aug 1, 2011 9:07 AM

View Postjrok, on Mon Aug 1, 2011 12:19 AM, said:

View PostJr. Pac, on Sun Jul 31, 2011 11:13 PM, said:

Can you please make one with dots worth 10 points each? That would be great!

Why don't you make one with dots worth 10 points each?

Or is RT supposed to write "your" game? :ponder:
I need to learn before I write code. :roll: I don't know how. Isn't it possible, RT? How does the original Ms. Pac-Man/Pac-Man/Jr. Pac-Man/clones use it? It has to be possible.

#16 GroovyBee OFFLINE  

GroovyBee

    7800 Developer

  • 5,781 posts
  • Busy bee!
  • Location:North, England

Posted Mon Aug 1, 2011 9:13 AM

View PostJr. Pac, on Mon Aug 1, 2011 9:07 AM, said:

I need to learn before I write code. :roll: I don't know how.

Its normal to learn while you write code. If you can't handle RT's example you really should be experimenting with other peoples code or start with far simpler things before you try and write a full game.

#17 jrok OFFLINE  

jrok

    Stargunner

  • 1,108 posts

Posted Mon Aug 1, 2011 9:26 AM

View PostJr. Pac, on Mon Aug 1, 2011 9:07 AM, said:

View Postjrok, on Mon Aug 1, 2011 12:19 AM, said:

View PostJr. Pac, on Sun Jul 31, 2011 11:13 PM, said:

Can you please make one with dots worth 10 points each? That would be great!

Why don't you make one with dots worth 10 points each?

Or is RT supposed to write "your" game? :ponder:
I need to learn before I write code. :roll: I don't know how.

If you mean that you don't have any programming experience at all, then perhaps you should start simple. I'd think that asking someone to write your game for you defeats the purpose of the hobby.

View PostJr. Pac, on Mon Aug 1, 2011 9:07 AM, said:

Isn't it possible, RT? How does the original Ms. Pac-Man/Pac-Man/Jr. Pac-Man/clones use it? It has to be possible.

RT is referring to the setup of the bB 1.0 standard kernel, which draws the entire screen at once, including the five objects he mentioned and the playfield pixels. Atari's Pac-Man "dots" were done with done with playfield pixels (which is why they look more like "dashes"), and the three ghosts were created by flickering player0 and player1 on alternating frames. I'd recommend you also go with playfield pixels for your dots.

#18 Jr. Pac OFFLINE  

Jr. Pac

    Dragonstomper

  • 775 posts
  • 1/4 of the fun with an Atari cart is cleaning it.
  • Location:In my room with my 2600.

Posted Mon Aug 1, 2011 9:29 AM

View PostGroovyBee, on Mon Aug 1, 2011 9:13 AM, said:

View PostJr. Pac, on Mon Aug 1, 2011 9:07 AM, said:

I need to learn before I write code. :roll: I don't know how.

Its normal to learn while you write code. If you can't handle RT's example you really should be experimenting with other peoples code or start with far simpler things before you try and write a full game.
:? I don't know what you mean. I can handle RT's code.

#19 Jr. Pac OFFLINE  

Jr. Pac

    Dragonstomper

  • 775 posts
  • 1/4 of the fun with an Atari cart is cleaning it.
  • Location:In my room with my 2600.

Posted Mon Aug 1, 2011 9:33 AM

View Postjrok, on Mon Aug 1, 2011 9:26 AM, said:

View PostJr. Pac, on Mon Aug 1, 2011 9:07 AM, said:

View Postjrok, on Mon Aug 1, 2011 12:19 AM, said:

View PostJr. Pac, on Sun Jul 31, 2011 11:13 PM, said:

Can you please make one with dots worth 10 points each? That would be great!

Why don't you make one with dots worth 10 points each?

Or is RT supposed to write "your" game? :ponder:
I need to learn before I write code. :roll: I don't know how.

If you mean that you don't have any programming experience at all, then perhaps you should start simple. I'd think that asking someone to write your game for you defeats the purpose of the hobby.

View PostJr. Pac, on Mon Aug 1, 2011 9:07 AM, said:

Isn't it possible, RT? How does the original Ms. Pac-Man/Pac-Man/Jr. Pac-Man/clones use it? It has to be possible.

RT is referring to the setup of the bB 1.0 standard kernel, which draws the entire screen at once, including the five objects he mentioned and the playfield pixels. Atari's Pac-Man "dots" were done with done with playfield pixels (which is why they look more like "dashes"), and the three ghosts were created by flickering player0 and player1 on alternating frames. I'd recommend you also go with playfield pixels for your dots.
I'm just asking for a snippet of code. What about the Pac-Man clones with dots, not "Video Wafers?" I would need extra big sprites for the characters to to make dots, because the "lanes" would have to be 3 playfield pixels wide.

#20 jrok OFFLINE  

jrok

    Stargunner

  • 1,108 posts

Posted Mon Aug 1, 2011 9:37 AM

View PostJr. Pac, on Mon Aug 1, 2011 9:29 AM, said:

View PostGroovyBee, on Mon Aug 1, 2011 9:13 AM, said:

View PostJr. Pac, on Mon Aug 1, 2011 9:07 AM, said:

I need to learn before I write code. :roll: I don't know how.

Its normal to learn while you write code. If you can't handle RT's example you really should be experimenting with other peoples code or start with far simpler things before you try and write a full game.
:? I don't know what you mean. I can handle RT's code.

I think he means that you've just been handed a boat, a paddle, a net, a brand new fishing pole and a bucket of bait, but now you are asking someone to catch the fish and cook them for you. ;)

Before you go any further, you might want to spend a few days modifying and experimenting with RT's code here. All of us were beginner programmers at one time, and I guarantee that's how most of us began to understand code and start writing our own.

Edited by jrok, Mon Aug 1, 2011 9:42 AM.


#21 jrok OFFLINE  

jrok

    Stargunner

  • 1,108 posts

Posted Mon Aug 1, 2011 9:41 AM

View PostJr. Pac, on Mon Aug 1, 2011 9:33 AM, said:

View Postjrok, on Mon Aug 1, 2011 9:26 AM, said:

View PostJr. Pac, on Mon Aug 1, 2011 9:07 AM, said:

View Postjrok, on Mon Aug 1, 2011 12:19 AM, said:

View PostJr. Pac, on Sun Jul 31, 2011 11:13 PM, said:

Can you please make one with dots worth 10 points each? That would be great!

Why don't you make one with dots worth 10 points each?

Or is RT supposed to write "your" game? :ponder:
I need to learn before I write code. :roll: I don't know how.

If you mean that you don't have any programming experience at all, then perhaps you should start simple. I'd think that asking someone to write your game for you defeats the purpose of the hobby.

View PostJr. Pac, on Mon Aug 1, 2011 9:07 AM, said:

Isn't it possible, RT? How does the original Ms. Pac-Man/Pac-Man/Jr. Pac-Man/clones use it? It has to be possible.

RT is referring to the setup of the bB 1.0 standard kernel, which draws the entire screen at once, including the five objects he mentioned and the playfield pixels. Atari's Pac-Man "dots" were done with done with playfield pixels (which is why they look more like "dashes"), and the three ghosts were created by flickering player0 and player1 on alternating frames. I'd recommend you also go with playfield pixels for your dots.
I'm just asking for a snippet of code. What about the Pac-Man clones with dots, not "Video Wafers?" I would need extra big sprites for the characters to to make dots, because the "lanes" would have to be 3 playfield pixels wide.

Oh, well that's simple then. Just write a custom kernel that allows you to display both missiles and the ball on every line. Then, perhaps with 30hz flicker, you could get up to 8 square "dots" on each scanline. It's an easy fix... just a "code snippet" really. :D

RT could you jump on that ASAP, so that Junior Pac can complete his masterpiece?

#22 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,923 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Mon Aug 1, 2011 9:52 AM

View PostJr. Pac, on Mon Aug 1, 2011 9:07 AM, said:

Isn't it possible, RT? How does the original Ms. Pac-Man/Pac-Man/Jr. Pac-Man/clones use it? It has to be possible.
They used assembly language. You might want to read Racing the Beam:

http://www.amazon.co...s/dp/026201257X


And although it's not about Pac-Man games, you might want to watch this video:

www.youtube.com/watch?v=MBT1OK6VAIU



batari Basic is amazing because it lets average people who only know BASIC style languages get the beginnings of a game up on the screen in minutes instead of days or months. The speed and ease of use come at a cost, though. For example, we can't have hundreds of dots on the screen and we can't have 50 multicolored sprites flying around. We have to figure out how to make fun games within the limitations of bB or learn assembly language or move on to something like Multimedia Fusion 2:


www.youtube.com/watch?v=2x-wq5RIwbA




The guy is speaking French, but the two videos below show him making a Pac-Man type game:

www.youtube.com/watch?v=IuQT4oliWko


www.youtube.com/watch?v=Jd90YtEfWcQ

Edited by Random Terrain, Mon Aug 1, 2011 9:58 AM.


#23 johnny_boy OFFLINE  

johnny_boy

    Chopper Commander

  • 147 posts

Posted Mon Aug 1, 2011 12:16 PM

Random Terrain, you are a very patient man. Kudos to you.

#24 NE146 OFFLINE  

NE146

    Dumbass Atari Fan

  • 12,576 posts
  • Location:Seattle, WA

Posted Mon Aug 1, 2011 12:24 PM

View PostJr. Pac, on Mon Aug 1, 2011 9:07 AM, said:

I need to learn before I write code. :roll: I don't know how.

do.jpg

#25 jrok OFFLINE  

jrok

    Stargunner

  • 1,108 posts

Posted Mon Aug 1, 2011 2:16 PM

View PostRandom Terrain, on Mon Aug 1, 2011 9:52 AM, said:

For example, we can't have hundreds of dots on the screen and we can't have 50 multicolored sprites flying around.

Well, I doubt we could have 50 sprites flying around, but hundreds of dots should be possible. You would just have to make some creative use of the sprites and flicker.

For instance, in the following binary the first example shows a grid of 384 dots (using both P0 and P1), and the second example shows a 9x6 dot grid, using only a single player sprite. Press and release the fire button to toggle between examples.

Attached File  Dots.bas.bin   32K   30 downloads

It looks okay in Stella with Phospor turned on. I just mocked these up real quick, but ultimately for a "dot-eater maze game", I think the idea would be to make use of the multiplexed P1 in the DPC+ kernel. In that case, you could potentially have 9 independent sprite rows on one frame, resizing them to %00000011 to get 27 dots. Then you could do the same on the next frame, but reposition their x to create a 30hz grid of 54. By tracking the position of the "eater" versus the grid, you could resize each sprite accordingly, making the dots vanish as you "eat" them. 54 isn't a heck of a lot of dots, but it's probably doable in pure bB (DPC+).

Edited by jrok, Mon Aug 1, 2011 3:09 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users