Daily Archives

Articles indexed Sunday November 25 2012

Page 13/14 | < Previous Page | 9 10 11 12 13 14  | Next Page >

  • Collision resolution - Character walking on ascendent ground

    - by marcg11
    I don't know if the solution to this problem is quite straight-foward but I really don't know how to handle collision resolution on a game where the player walks on an ascendent floor which is not flat. How can the player position itself on the y axis depend on the ground x and z (opengl coords)? What if the floor's slope is too much and the player can't go up, how do you handle that? I don't need any code, just a simple explanation would be great.

    Read the article

  • XNA Health Bar continually decreasing

    - by Craig
    As per the Health bar tutorial on ... http://www.xnadevelopment.com/tutorials/notsohealthy/NotSoHealthy.shtml I have set up the above, how do I make it decrease by 1 health per second? I want to create a mini survival game, and this is an important factor. Where am i going wrong? I want it to visibly decrease every second. using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; namespace Health { /// <summary> /// This is the main type for your game /// </summary> public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Texture2D healthBar; int currentHealth = 100; float seconds; public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; } /// <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(); } /// <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); healthBar = Content.Load<Texture2D>("HealthBar"); // 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) this.Exit(); // TODO: Add your update logic here currentHealth = (int)MathHelper.Clamp(currentHealth, 0, 100); seconds += (float)gameTime.ElapsedGameTime.TotalSeconds; if (seconds >= 1) { currentHealth -= 1; } seconds = 0; base.Update(gameTime); } /// <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) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); spriteBatch.Draw(healthBar, new Rectangle(this.Window.ClientBounds.Width / 2 - healthBar.Width / 2, 30, healthBar.Width, 44), new Rectangle(0, 45, healthBar.Width, 44), Color.Gray); spriteBatch.Draw(healthBar, new Rectangle(this.Window.ClientBounds.Width / 2 - healthBar.Width / 2, 30, (int)(healthBar.Width * ((double)currentHealth / 100)), 44), new Rectangle(0, 45, healthBar.Width, 44), Color.Red); spriteBatch.Draw(healthBar, new Rectangle(this.Window.ClientBounds.Width / 2 - healthBar.Width / 2, 30, healthBar.Width, 44), new Rectangle(0, 0, healthBar.Width, 44), Color.White); spriteBatch.End(); base.Draw(gameTime); } } } Cheers!

    Read the article

  • How to disguise a serverside mob as another?

    - by Shaun Wild
    I've been working a Minecraft sever mod and i want to be able to add a new entity to the server, but then make the server send the packets to the client, imitating another mob, for example.. Lets say say i have EntityPlayerNPC.class, what i want to do is have all of the packets that get sent to the client look like they are from that of another player which is on the player, therefore allowing me to add custom NPC's... Thinking about the theory i'm sure this can be done. I've tried looking around for where the packets are being sent from and whatnot, can anyone think up a solution? edit: i tried adding a new constructor to the Packet20NamedEntitySpawn class like so: public Packet20NamedEntitySpawn(String username, EntityLiving e){ this.entityId = 0; this.name = username; this.xPosition = MathHelper.floor_double(e.posX * 32.0D); this.yPosition = MathHelper.floor_double(e.posY * 32.0D); this.zPosition = MathHelper.floor_double(e.posZ * 32.0D); this.rotation = (byte)((int)(e.rotationYaw * 256.0F / 360.0F)); this.pitch = (byte)((int)(e.rotationPitch * 256.0F / 360.0F)); this.metadata = e.getDataWatcher(); } unfortunatley, that didn't work :(

    Read the article

  • D20 java engine

    - by javydreamercsw
    I'm trying to incorporate PCGen into my application to avoid recreating the wheel for D20 system. (Are there any other libraries out there?) In other words I would like to use PCGen as a library and do things like: CRUD characters (and all related information) Experience/level managements I don't need the GUI part of it just the information to pass to my application. This is a scenario I can think of: 1. Load available custom classes 2. Create a new Character/NPC 3. Transfer the stats to my system 4. Player keeps playing so I need to update experience 5. Save player in my system and recreate it later. I'm trying to start to create a character from PCClass with no luck. Looking at the code it seems it'll try to load it. I assume load from a file generated from the GUI. Is there a way of bypassing the GUI for all this? I was looking for a tutorial of some sorts without luck. I was able to figure out how to use the dice within PCGen but that's about it. Any ideas?

    Read the article

  • How can I calculate the angle between two 2D vectors?

    - by Error 454
    I am working on some movement AI where there are no obstacles and movement is restricted to the XY plane. I am calculating two vectors, v, the facing direction of ship 1, and w, the vector pointing from the position of ship 1 to ship 2. I am then calculating the angle between these two vectors using the formula arccos((v · w) / (|v| · |w|)) The problem I'm having is that arccos only returns values between 0° and 180°. This makes it impossible to determine whether I should turn left or right to face the other ship. Is there a better way to do this?

    Read the article

< Previous Page | 9 10 11 12 13 14  | Next Page >