Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [2D PacMan Game Project] *closed*  (Read 4245 times)
0 Members and 1 Guest are viewing this topic.
Offline GabrielBailey74
« Posted 2012-02-16 07:35:58 »

Thought I'd like to bring my project to this community after a few hours of actually thinking how i'm going to do it.

Updates done:
  • AudioSystem via Java (2 tracks atm: Menu, Game)
  • Basic HighDetail PacMan sprites, (not a black circle dumped with yellow..)
  • Same above for NPC sprites + some animation for ghostys
  • Menu Screen
  • GameMap border collision detection
  • Depending on the last direction of travel, PacMan's image changes accordingly
  • Left, right, up, down movement of course no other way
  • We now have waka waka collision detection: (below)

Still TODO:
  • Adding NPC's
  • Full Maps
  • Adding waka waka candy sound effects
  • Keeping track of each rounds accumulated score
  • Tons more just getting started!

Pictures:

Main Menu Screen:

(PacMan's chasing the ghost, and with each lap the ghost gains more foot room on PacMan, constantly increasing their speeds =D)

Game Map Screen:

(Not much here yet, just drew a basic border map, lives, score).

Waka Waka's added + collision detection with le PacMan:


Hope to get some positive feedback on this one.
I feel that NPCs was the biggest part of PacMan, I still have yet to do that, looking forward to it.
Any update ideas or things that you think should be added to my TODO list, please comment with them.

Offline ReBirth
« Reply #1 - Posted 2012-02-16 11:12:21 »

You want comment of current progress or suggestions?

Offline Cero
« Reply #2 - Posted 2012-02-16 14:56:18 »

you may wanna watch the "making of" of the google pac-man

Google I/O 2011: The Secrets of Google Pac-Man: A Game Show

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline GabrielBailey74
« Reply #3 - Posted 2012-02-16 23:37:45 »

Well i overdid it last night: (waka waka detection got messed up)
Here's the coding (probably remove this later today):

NEED HELP:
Here is what is currently detecting if the 'PacMan', is over the waka:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
   public static void handleWaka(Graphics g, int x, int y) {
      int wx = x;
      int wy = y;
      int px = PacMan.getX();
      int py = PacMan.getY();
      if (
         (px> 60 && px < 80)
            ) {
         System.out.println("W00t: X: "+x+". Y: "+y);  
         gotWaka(g, x, y);
         PacMan.setScore(PacMan.getScore() + 1);
      }
   }

(At the moment only detecting if he's in the first row).

Here is the piece of coding that calls that 'handleWaka' method (Draws them also):
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
   public static int[] wakas = new int[580];

   public static void drawWakas(Graphics g) {
      final Graphics2D g2d = (Graphics2D) g;
      int space = 30;
      for (int i = 70; i < wakas.length; i += space ) {
         wakas[i] = i;
         drawWaka(g, 70, i);
         handleWaka(g, i, i);
      }
   }


What I need help with is a method of drawing the waka wakas candy (row by row), and also storing their coordinates, (or presorting them in a int[] array).

Offline StonePickaxes

JGO Coder


Medals: 4
Projects: 2


Nathan Kramber


« Reply #4 - Posted 2012-02-21 13:53:47 »

Here's what I did for the map. I made a 2D array that stored the walls and bullets, and cycled through it in a constructor for the class "Level", and when it detects a pellet it adds a new one to the pellet list along with x and z coordinates, same with the walls.

Example:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
int[][] level = {
         {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
         {0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,},
         {0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,},
         {0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,},
         {0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,},
         {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,},
         {0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,},
         {0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,},
         {0,1,1,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,0,},
         {0,0,0,0,0,0,1,0,0,0,0,0,2,0,0,2,0,0,0,0,0,1,0,0,0,0,0,0,},
         {2,2,2,2,2,0,1,0,0,0,0,0,2,0,0,2,0,0,0,0,0,1,0,2,2,2,2,2,},
         {2,2,2,2,2,0,1,0,0,2,2,2,2,2,2,2,2,2,2,0,0,1,0,2,2,2,2,2,},
         {2,2,2,2,2,0,1,0,0,2,2,2,2,2,2,2,2,2,2,0,0,1,0,2,2,2,2,2,},
         {2,2,2,2,2,0,1,0,0,2,2,2,2,2,2,2,2,2,2,0,0,1,0,2,2,2,2,2,},
         {2,2,2,2,2,0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,0,2,2,2,2,2,},
         {2,2,2,2,2,0,1,0,0,2,2,2,2,2,2,2,2,2,2,0,0,1,0,2,2,2,2,2,},
         {2,2,2,2,2,0,1,0,0,2,2,2,2,2,2,2,2,2,2,0,0,1,0,2,2,2,2,2,},
         {2,2,2,2,2,0,1,0,0,2,2,2,2,2,2,2,2,2,2,0,0,1,0,2,2,2,2,2,},
         {2,2,2,2,2,0,1,0,0,2,2,2,2,2,2,2,2,2,2,0,0,1,0,2,2,2,2,2,},
         {0,0,0,0,0,0,1,0,0,2,0,0,0,0,0,0,0,0,2,0,0,1,0,0,0,0,0,0,},
         {0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,},
         {0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,},
         {0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,},
         {0,1,1,1,0,0,1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1,0,0,1,1,1,0,},
         {0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,},
         {0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,},
         {0,1,1,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,0,},
         {0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,},
         {0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,},
         {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,},
         {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,}
      };

        public Level(Main main)
   {
      this.main = main;
     
      for (int x = 0; x < 28; x++)
      {
         for (int y = 0; y < 31; y++)
         {
            mapData = level[y][x];
           
            if (mapData == 0)
            {
               Wall wall = new Wall(main);
               wall.setX(x);
               wall.setY(y);
               main.wallList.add(wall);
            }
           
            if (mapData == 1)
            {
               Pellet pellet = new Pellet(main);
               pellet.setX(x);
               pellet.setY(y);
               main.pelletList.add(pellet);
            }
           
            if (mapData == 3)
            {
               main.player.px = x * 13;
               main.player.py = y * 13;
            }
         }
      }
   }


Since the screen is going to be longer and wider than the array from above, I multiply the coordinates by 13 (the size of my sprites) to make them go in the right places. When I do collision detection with the walls, I draw rectangles around each piece of wall by cycling through the list, multiplying the x and y by 13 again to get the correct location, and using 13 as the height and width. Same thing with the pellets, except since they are only 4*4, I use 4 as the height and width instead of 13.

See it in action here, or here if that one is blocked.

p.s. I wish I had your art skills! So far my sprites were just ripped from the original game :x

-Nathan

Check out my website!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (53 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (42 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!