Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Cedra
Jul 23, 2007
I have 2 questions (I use XNA and C#):

What's the basics needed for a shoot 'em up ala Ikaruga or Touhou? So far I've gathered that there should be a Game class for the logic, a Player class for the player sprite and projectile class for the bullets. There probably should be an enemy class as well.

My main problem is figuring what goes inside those classes, mainly projectile. How would one go about setting up all those fancy bullet patterns, the timings of when a particular enemy appears and how they fly into the screen?



Secondly, I was hammering away at XNA and tried making a sprite jump like Mario. My code is this:

code:
(Input method within Game.cs)
            KeyboardState newState = Keyboard.GetState();

            if (newState.IsKeyDown(Keys.Space) && (oldState.IsKeyDown(Keys.Space) == false))
            {
                jumpOK = true;
                spritePosition.Y -= 1;
                yvel = 2.01f;
            }


(Update method within Game.cs)

float initialTime = (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            if (jumpOK == true)
            {
                if (spritePosition.Y < 400)
                {
                    ypos += yvel; //* elapsedSeconds;//(float)gameTime.ElapsedRealTime.TotalSeconds;
                    yvel += yacc * (float)gameTime.ElapsedRealTime.TotalSeconds; //* elapsedSeconds; //0.0166...666667f;
                    spritePosition.Y -= ypos;
                }
                else
                {
                    spritePosition.Y = 400;
                    yvel = 0;
                    ypos = 0;
                    jumpOK = false;
                }
            }

            base.Update(gameTime);
        }
The commented out parts were experiments trying out different variables. If there's anything missing that you need to better understand the code please let me know.

Anyway, I've been trying to achieve a consistent apex with no luck. It's been about 6 months since I looked at the code but from what I remember the apex sometimes differs due to the reliance on gametime as part of the velocity calculation. Also, the sprite doesn't quite have that snappyness of a classic Mario jump.

Basically, is there a better way to program a jump function, or can this current code be modified to allow a faster ascent while coming down slower (I think this is what Mario does)?

Cedra fucked around with this message at 16:17 on Feb 25, 2008

Adbot
ADBOT LOVES YOU

Cedra
Jul 23, 2007
Does anyone have any good tutorial links to a tile engine in C#? I've been following XNAResources.com but their tutorials are outdated and ever since updating to XNA 2.0 things like EnsureDevice(), BeginScene() and EndScene() are broken and I've little idea of how to fix them.

Cedra
Jul 23, 2007

stromdotcom posted:

I've only glanced briefly at it, but this looks good: http://www.kersson.com/articles/article.aspx?ar=41

Thanks very much! I'm slowly going through it, trying to understand the reasonings behind the code (something I find lots of tutorials lack - they just lead you with little explanation as to why they're doing it). Halfway through this page, I don't get what this is snippet from the TileSet class is supposed to do:
code:
public Rectangle Rectangle(int position)
{
 return rectangles[((position-1) / columns), ((position - 1) % columns)];
}
From what I'm reading, it's to find a specific tile? But let's use the example image he has provided. He's labelled the 6 tiles as

123
456

So let's place the number 6 as the position parameter, and columns 3. rectangles would come out as [2 (or 1.67 rounded up),2], which I think would take tile 9, no?? (this is C# btw)

Cedra
Jul 23, 2007

ShoulderDaemon posted:

Integer arithmetic does not round, it truncates. 5 / 3 = 1.

Right, right. That makes sense, thanks.

Cedra
Jul 23, 2007
OpenGL question: How do I make a light that's fixed relative to my eye?

As per the Nehe tutorials, I've set up the light's ambience and diffuse intensities, added the LIGHT_POSITION property and enabled lighting in the init() method. And that's it. Yet whenever I rotate/translate/scale my model using a threaded Display() loop, the lights seem to rotate with it as well.

This is confusing. I think I'm following the OpenGL FAQ's answer too ("How can I make my light position stay fixed relative to my eye position? How do I make a headlight?"), yet my results do not match it. I'm not updating the position whatsoever, so should it not stay in the same position?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply