yothsoggoth's Profile User Rating: -----

Reputation: 19 Tradesman
Group:
Contributors
Active Posts:
49 (0.06 per day)
Joined:
19-June 12
Profile Views:
1,321
Last Active:
User is offline Jun 10 2014 12:43 PM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Linux
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
50

Latest Visitors

Icon   yothsoggoth has not set their status

Posts I've Made

  1. In Topic: DirectX 9 and rendering to a texture.

    Posted 13 May 2014

    On line 6, you have renderTarget == NULL; which I think should be renderTarget = NULL;. That's not causing you any issues at the moment, because the first thing you do after that statement is renderTarget = NULL; anyway, but nonetheless you should correct that, or remove the line altogether.

    Also, are you intentionally setting the render target at index 1? I would assume you want to be setting the render target at index 0?
    i.e. device3d->SetRenderTarget(0, renderTarget); and device3d->SetRenderTarget(0, windowTarget);
  2. In Topic: SDL How to animate a Sprite when key is pressed?

    Posted 2 May 2014

    A common, and very easy, method of doing this is to keep an animation timer which is constantly increased and used to determine which frame of the animation to show. Also, it helps if you have each different animation on it's own row in the sprite sheet.

    For example
    | WalkingLeft1 | WalkingLeft2 | WalkingLeft3 |
    | WalkingRight1 | WalkingRight2 | WalkingRight2 |
    | ...etc... | | |

    Then when you change which type of animation you need, you set the Y component of the sample rectangle.

    As the game runs, update AnimationTimer by the time passed in that frame. (e.g. AnimationTimer += frameTime). Then, your X component can be given as something like SpriteClipX = (AnimationTimer / AnimationFPS) * SpriteWidth

    Then, if you change state or if the animation timer reaches greater than SpriteWidth * NumberOfFrames reset AnimationTimer to zero.

    (I wrote this quickly on my phone, so there may be some mistakes)
  3. In Topic: [C++/Allegro 5] Problem with drawing correctly in a 2D iso view

    Posted 22 Apr 2014

    View PostNicky24, on 22 April 2014 - 08:39 AM, said:

    Thanks for this clear answer! I will try to do it that way.

    But do I need to create a container (vector) of all the Renderables? And then use sort() on it?

    Thanks

    Ah, sorry I was going to mention that in my first reply, but when I saw the code you'd quoted that used the sort I had assumed you'd already done that bit.

    Well, my previous answers were based on the assumption you were already using a vector of Renderables, and yes you can do that and it will work fine.

    Depending on whether or not you intend to use the same container for anything else, you may wish to choose a different container than a vector (e.g. if you needed to perform fast lookups based on an ID or anything), however based on the scenario you've described I think a vector will be just fine.
  4. In Topic: [C++/Allegro 5] Problem with drawing correctly in a 2D iso view

    Posted 21 Apr 2014

    Well, from your images it would appear that whichever character (player or non) is further "down" the screen will be infront of those behind it. Therefore, the Y position of the character can also be used to represents its draw order.

    So, if you set things in the background to Z=-1 to ensure they will always be drawn first, then anything in the foreground (e.g. things that players/characters will "disappear" behind) to Z=MaxScreenY+1 they will be draw last. Then, for the rest of the scene, the Z position could equal the Y position on screen.

    Then, each frame before rendering you sort the Renderables by the Z values that have been set, and draw them one by one.

    [Edit] It may also be worth pointing out that you should probably use the "bottom" Y value of the sprites as that's where they appear to touch the floor (Probably SpriteY+SpriteHeight in most cases, as the sprite coordinates tend to be the top-left)
  5. In Topic: [C++/Allegro 5] Problem with drawing correctly in a 2D iso view

    Posted 20 Apr 2014

    You seem to have mostly solved this, unless I'm missing something in your question...

    Can't you just set a Z position and use that to determine the drawing order?

    For example, for your NPCs and player, their Z could equal their Y, and for things like the background, or scene elements, they can use a predetermined Z position to keep them behind or in front of other objects as required.

My Information

Member Title:
New D.I.C Head
Age:
21 years old
Birthday:
October 14, 1992
Gender:
Location:
England
Full Name:
Joe
Years Programming:
9
Programming Languages:
C++, C#, Python, PHP, Javascript, Java, VB.Net

Contact Information

E-mail:
Private
Website URL:
Website URL  http://www.robotgoblin.co.uk/
Twitter:
joeydotnet

Comments

yothsoggoth has no profile comments yet. Why not say hello?