Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 18 Apr 2012
Offline Last Active Feb 14 2014 06:49 PM

Topics I've Started

[PlaystationMobile, XNA] Need Help with the Syntax for a Simple 3D Effect

20 January 2014 - 06:02 PM

Hey guys, I have been porting a game made in XNA, a 2D RPG, to PSM using Monogame.  Unfortunately, I use a simple 3D effect that cannot be translated because Monogame did not write translation code for the BasicEffect class.


The effect is a simple 3D manipulation used in battle.  I know almost nothing about 3D coding so it was a struggle to get this work in XNA to begin with.


Here's how it works.  Enemies in battle don't move and are just standard sprites from a spritesheet, like this:



The enemy sprite is like a wooden cut out from a shooting gallery.  Now certain actions can move it around.  For example if you hit the enemy it will tilt back and forth.






Now the logic behind how this works is very simple, although it was difficult for me to find the right syntax.  I'm simply manipulating the verticies that draw the sprite.  For example, if I want it to look like it's tilting back, I simply move the top left vertex down and left and the top right vertex down and right.


Here's what the code for tilting looks like in my XNA code.

public void TiltBackward(GameTime gameTime)
            if (transitionTimer >= tiltForwardInterval)
                transitionTimer = TimeSpan.Zero;
                TiltFinished = true;
                transitionTimer += gameTime.ElapsedGameTime;

                gpuVertices[0].Position.X =
                    startVertices[0].X +
                    (((float)entity.Width * (float)bits / 4f) * (float)Math.Min(1,(transitionTimer.TotalSeconds / tiltForwardInterval.TotalSeconds)));

                gpuVertices[1].Position.X =
                    startVertices[1].X +
                    (((float)-entity.Width * (float)bits / 4f) * (float)Math.Min(1,(transitionTimer.TotalSeconds / tiltForwardInterval.TotalSeconds)));

                gpuVertices[0].Position.Y =
                    startVertices[0].Y +
                    (((float)entity.Height * (float)bits / 4f) * (float)Math.Min(1,(transitionTimer.TotalSeconds / tiltForwardInterval.TotalSeconds)));

                gpuVertices[1].Position.Y = gpuVertices[0].Position.Y;

The XNA code that draws it uses syntax that I don't fully  underestand, like rasterized states, index buffers, basiceffect passes.  Here's what that looks like in XNA.

 basicEffect.Texture = image;
                basicEffect.VertexColorEnabled = true;
                basicEffect.TextureEnabled = true; //Will make colors black instead of red


                graphics.Indices = indexBuffer;

                graphics.RasterizerState = rasterizerState;
                foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)



  private void DrawTriangleStrip()


So now I need to simply translate this code to the PSM native language.  This is a difficult task for someone who barely understands the original syntax, has been using Monogame to port, and doesn't really understand 3D coding to begin with.


I've looked at all the examples and looked up some things in the SDK.  It seems like to pull this off all I would need to do is manipulate the quad points.  Unfortunately, those are read only and cannot be changed manually.  


I understand the logic, I just can't figure out the syntax.  This is a problem where anyone with even a passing familiarity in 3D coding for PSM could tell me exactly how to do this in seconds.  But I've spent days trying to figure it out without any success.  I'm hoping such a person can throw me a bone. 

Slow loading xml/xnb as data type on PS Vita

01 November 2013 - 12:40 PM

I'm having trouble with loading times on the Vita and was looking for general suggestions.  I'm sort of stuck as I lack competency in xml reader coding and have a tenuous grasp of content loading in general.
Some background, I'm porting a game from XNA to PSM using Monogame.  So my XMLs are being loaded as XNB custom data types like so:

MapData mapData = Content.Load<MapData>(@"Game\Levels\Maps\" + name);

 Now to be fair, the xmls for these maps are enormous to begin with.  One of my larger maps is 4.87 mb as an XML, 257 KB as an XNB and takes about 35 seconds to load (which is way too long for a 2D RPG).
I'll show you a typical map data xml file so you can get an idea of what these long loading files look like http://pastebin.com/raw.php?i=rs6SqTd5
I suppose I either need to find to find a faster way to load them or else find smaller way to represent map data.  I'm hoping there's an solution for the former.

How could I possibly get a user’s save file to transfer to a sequel game?

31 January 2013 - 12:49 AM

It’s a tough question. 
One I have casually asked before, but now I must seriously consider how
this could possibly be done.


I don’t know much about coding save systems.  I figured mine out for my game about 7 months
ago.  Starting the game for the first
time creates a folder in windows Isolated Storage (with some gobbledegook
name).  Saving creates an xml file in
this folder with all the saved data.  The
player can then load this save file when resuming the game.  (I can include this code if necessary).

Simple enough although I don’t exactly have a clear grasp on how it
all works.


But back to the burning question before I lose your
attention.  I want the user to be able to
play a different game, a sequel, using their old save file (so they can keep
all the experience, equipment, etc. learned). 
The save files are quite large (500KB) as this is an RPG.

It might be doable on Windows.  I might be able to better control where the
save file is created and where it is loaded from with both games.

On the Xbox, it is an entirely different matter.  From what I’ve heard, there is simply no way
to do this.  I’m hoping that isn’t
true.  Maybe through some kind of online
storage?  Or perhaps a complex password


Has anyone ever attempted such a thing before?

New to 3D/Matricies - Need help getting texture to display

19 July 2012 - 03:29 PM

(Solved...for now)

Need help transforming a 2D image

17 July 2012 - 05:21 PM

EDIT: Solved...at the moment

Working on a game in XNA with C#. I posted this in the creator's club forum and didn't get much help so I thought I'd give it a shot here.

For our RPG, we have enemy sprites that spin and fall down when dodging, hit and defeated - like in an old west shooting gallery.

You can check out the effect in this video demonstrating our combat system:


It's a neat effect but there's nothing fancy going on here. This is done simply by manually distorting the original sprite in photoshop and creating an animation. Here is an enemy spritesheet:

Posted Image

The problem is, it takes a long time to manually create these animations and it's prone to human error.
It would be fantastic if there was a way to code the same effects from the original sprite (in 2D). I looked into it before, but gave up as it seemed too complex for me.

However, faced with how long it takes to do manually, I thought it would be worth a shot to see if anyone can help me out and point me in the right direction to code the effect.