ya, I think I'll work on a menu eventually(Probably going to put a delay in the beginning with a countdown or something to let you get ready before the game starts next release), just trying to get the actual gameplay down first. As for why some people's music isn't playing I have no idea... Make sure you have the volume up when you start the game cause XNA seems to use that as the max volume, also try pressing up, that'll increase the volume in the game(although only to the volume it was when it started, I think that might be a bug in XNA but idk). Aside from that I hope you guys are enjoying it so far.
would it be possible to add some comments to your code? i can figure out most of it, but i dont want to spend the time if i dont have to. I Want to change a few things to make it more likeable to me (IE: Add support for the zune pad, Keep the paddle from constantly moving, ect...) Great work so far though!!!! its pretty fun
have to give this guy a playtest, i'm surprised we already have so many games to play.
edit: after playing the game a lil I want to say kudos, it is pretty fun, that damn computer is next to impossible to score against, and I like the random song play.
How ever the freezing problem is still there. curious thing I noticed, when it's frozen if you hit the play/pause button it still switches songs lol.
hmm strange that the freezing is still there for so many of you... Is everyone getting it(i.e. if anyone isn't please say so)? Either way I'll try redeploying to my zune and seeing if that brings it back and if not, try to make sure the version I have up is current. (By the way if you get good enough you beat the computer every time cause he can't keep up at high speeds, I might try to change that to make him more challenging at higher speeds)
ok so for whatever reason it looks like when I tried to put up the new version this morning I must have put up the old version again. Hopefully that fixes everyone's issues.
meh.. i do agree that this game freezes a lot.. whenever you push the back button your zune will freeze.. and you have to hold down the back button to let it actually exit on my zune.. >.<
__________________
1.Window > Linux > Mac
2. Sony Ericsson > Nokia > Samsung
3.
4. don't forget to rep me
kudos on the redesign bro. For fun and extra challenge how about a bonus round where you must keep up with 2+ balls at the same time? And perhaps a music visualizer in the background, and as the temp of the music increases the speed of the balls increases as well. Dunno if it would work or not, just thought that music integration with the gameplay would be a nice touch
I think I solved the "Freezing" problem, where the music still plays: seeing how it happens with the zune 80 (which I have) and not the zune 30. I am sorry to say, you have pressed the center button and put the game on pause. yes, I said it, paused.
So with that outta the way, good game marcus!
__________________
\nn/===IRON MAIDEN RULES===\nn/
Xbox live/Zune= Epocilyps. Invites are fine. need people with zunes on my friends list.
I changed it to get rid of the acceleration based control, now left moves it left and right moves it right. To apply the change replace game.cs with:
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.GamerServices;
using XnaTetris.Graphics;
using System.Threading;
namespace Pong
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Texture2D ball;
Texture2D paddle;
Texture2D albumart;
Texture2D talbumart;
float p1x = 105;
int p1y = 0;
int score = 0;
float p1s = 0;
string error;
float p2x = 105;
int p2y = 275;
float p2s = 0;
float ballx = 120;
float bally = 160;
float ballsx = 1.0f;
float ballsy = 1.0f;
long numframes = 0;
string info;
bool changesong;
Thread albuminfoloader;
bool paused, pchange=false, volume=false;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
MediaPlayer.IsShuffled = true;
MediaLibrary ml = new MediaLibrary();
SongCollection s = ml.Songs;
MediaPlayer.Play(s);
MediaPlayer.Queue.MoveNext();
albuminfoloader = new Thread(new ThreadStart(LoadAlbumInfo));
albuminfoloader.Priority = ThreadPriority.Lowest;
albuminfoloader.Start();
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
p1x = 105;
p1y = 0;
p1s = 0;
p2x = 105;
p2y = 275;
p2s = 0;
ballx = 120;
bally = 160;
ballsx = 1.0f;
ballsy = 1.0f;
paused = false;
numframes = 0;
changesong = false;
error = "";
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
ball = Content.Load<Texture2D>("ball");
paddle = Content.Load<Texture2D>("paddle");
albumart = MediaPlayer.Queue.ActiveSong.Album.GetThumbnail(Content.ServiceProvider);
// TODO: use this.Content to load your game content here
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
{
MediaPlayer.Stop();
albuminfoloader.Abort();
this.Exit();
}
GamePadState gps = GamePad.GetState(PlayerIndex.One);
// TODO: Add your update logic here
if (!paused)
{
if (numframes > 100)
{
ballsy *= 1.0005f;
ballsx *= 1.0005f;
if (ballx + 10 > p1x && ballx < p1x + 30 && bally + ballsy < p1y + 5 && ballsy < 0)
{
ballsy = -ballsy;
ballsx -= .2f * p1s;
}
if (ballx + 10 > p2x && ballx < p2x + 30 && bally + ballsy + 10 > p2y && ballsy > 0)
{
ballsy = -ballsy;
ballsx -= .2f * p2s;
}
ballx += ballsx;
bally += ballsy;
}
p1x += p1s;
p2x += p2s;
if (bally < 0)
{
score++;
Initialize();
}
else if (bally > 270)
{
score--;
Initialize();
}
if (ballx < 0)
{
ballsx = -ballsx;
ballx = -ballx;
}
else if (ballx > 230)
{
ballx = 460 - ballx;
ballsx = -ballsx;
}
if (p1x < 0)
{
p1s = -p1s;
p1x = -p1x;
}
else if (p1x > 230)
{
p1x = 460 - p1x;
p1s = -p1s;
}
if (p2x < 0)
{
p2s = -p2s;
p2x = -p2x;
}
else if (p2x > 230)
{
p2x = 460 - p2x;
p2s = -p2s;
}
if (gps.DPad.Left == ButtonState.Pressed && p2s > -2-(.0005*numframes))
{
p2x -= 2.5f;
}
else if (gps.DPad.Right == ButtonState.Pressed && p2s < 2 + (.0005 * numframes))
{
p2x += 2.5f;
}
if (ballx < p1x)
{
p1x -= 2 + (.0005f * numframes);
}
else if (ballx > p1x + 30)
{
p1x += 2 + (.0005f * numframes);
}
numframes++;
}
if (gps.Buttons.A == ButtonState.Pressed && !pchange)
{
paused = !paused;
pchange = true;
}
if (gps.Buttons.A == ButtonState.Released)
{
pchange = false;
}
if (gps.DPad.Up == ButtonState.Pressed && !volume)
{
MediaPlayer.Volume+=.05f;
volume = true;
}
if (gps.DPad.Down == ButtonState.Pressed && !volume)
{
MediaPlayer.Volume -= .05f;
volume = true;
}
if (gps.DPad.Down == ButtonState.Released && gps.DPad.Up == ButtonState.Released)
{
volume = false;
}
base.Update(gameTime);
}
void LoadAlbumInfo()
{
bool album = false;
while (true)
{
GamePadState gps = GamePad.GetState(PlayerIndex.One);
info = (MediaPlayer.Queue.ActiveSong.Artist.ToString()) + ": " + MediaPlayer.Queue.ActiveSong.ToString();
if (gps.Buttons.B == ButtonState.Pressed && !album)
{
MediaPlayer.Queue.MoveNext();
changesong = true;
album = true;
}
else if (gps.Buttons.B == ButtonState.Released)
{
album = false;
}
if (gps.Buttons.Back == ButtonState.Pressed)
{
return;
}
}
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.Black);
// TODO: Add your drawing code here
spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
Rectangle r = new Rectangle((int)ballx, (int)bally, 10, 10);
spriteBatch.Draw(ball, r, Color.White);
r = new Rectangle((int)p1x, (int)p1y, 30, 5);
spriteBatch.Draw(paddle, r, Color.White);
r = new Rectangle((int)p2x, (int)p2y, 30, 5);
spriteBatch.Draw(paddle, r, Color.White);
if (changesong)
{
do
{
albumart = MediaPlayer.Queue.ActiveSong.Album.GetThumbnail(Content.ServiceProvider);
} while (albumart == null);
changesong = false;
}
r = new Rectangle(200, 280, 40, 40);
spriteBatch.Draw(albumart, r, Color.White);
spriteBatch.End();
TextureFont t =new TextureFont(GraphicsDevice, Content);
TextureFont.WriteText(30, 450, info);
t.WriteAll();
TextureFont.WriteText(30, 400, error);
t.WriteAll();
TextureFont.WriteText(30, 480, "Score: " + score);
t.WriteAll();
base.Draw(gameTime);
}
}
}
That's the only thing I changed around.
Besides that I'm having the freezing when changing songs thing it is a very cool little pong game. Add in a menu, ability to choose which songs you play (playlist or something) and a difficulty control and it would be epic.
Best game released so far
edit: yeah, the center thing was what I was doing. Why is everyone using the center button as pause? I keep hitting it by accident
Maybe add something that says PAUSED when paused and make the music pause when paused.
And instead of a pause before starting, maybe wait till you push a button
I know what's causing the freezing for a little when loading a new song, I'll get on working on that(I'm at the girlfriend's house so have to install visual studio et all here first). Also, I'm gonna get started on 2 player and a menu. Probably going to have different modes where the ball gets faster at varying degrees.
Hey all, so I fixed it so there is no freezing when changing song or at the beginning of the round, though it takes a second or two to load the album art now(but at least you can keep playing while it does!) Next up: Main menu and hopefully multiplayer.
please don't double post, and could you share the fixed files please
__________________
Quote:
Originally Posted by Marcus Aurelius
Live a good life. If there are gods and they are just, then they will not care how devout you have been, but will welcome you based on the virtues you have lived by. If there are gods, but unjust, then you should not want to worship them. If there are no gods, then you will be gone, but will have lived a noble life that will live on in the memories of your loved ones.
Yeah, I like it better without the accelaration. Thanks for that! But does anyone know how to make it so that the computer isn't quite so hard? It's like impossible to beat them.
Location: If there's a bright center to the universe, you're on the planet that's farthest from. -Wisconsin
Posts: 215
It's cool, acceleration is fun, but the ball does move too slowly, so I haven't even scored once yet, a ball freezing period would be nice, and it freezes when i adjust the volume. But like I said before, it's cool.
__________________
Props to stkr for the sweet sig!