locoflop

Members
  • Content count

    18
  • Joined

  • Last visited

Community Reputation

135 Neutral

About locoflop

  • Rank
    Member
  1. Hello, in this OpenTK application why can you get the perfect scale with Math.PI? http://www.opentk.com/node/2294   time = (time >= Math.PI) ? 0.0 : time + e.Time; variableScale = (float)(Math.Sin(time)); I know that Sin works best for 0..360 circle degrees range, but Math.PI related to time is strange.   If you have any references about and links to share please post here. Thanks.  
  2. Understanding Tiled TMX gids.

    Thanks a lot, this snippet helped me to clarify things a bit. Clever approach to iterate through all of the tilesets.
  3. xna dead. now what?

    Here is my favourites (random order): SharpDX: If you want DirectX support currently better for Windows PC, perhaps in the future also for tablets/mobile. There was an ongoing vote to convice Microsoft to enable some functionality that could allow developers to support mobile/tablet devices running Windows 8, but who knows what happened. OpenTK: Very good for cross platform (Windows/Mac/Linux), unfortunately support is halted so you must use the repo of Andy Korth at github in order to get the latest version. Also if you are interested in MonoTouch and MonoDroid chances are that you can reuse most of your code. Pencil.Gaming: An evolution of OpenTK, more clean and practial. It looks like a polished version of OpenTK that is tied to GLFW3 instead for Window management. Unity: You will have to use it to believe. For me personally, let me do other creative things in game rather than system development. It's a matter of where exactly is your interest.
  4. Have any one looked at the Tiled format?   One thing that I try to understand is if a layer contains tiles from two tilesets, then how you can understand which tile originates from a specific tileset.   For example: f tileset A consists of a region of numbers 1 to 19 then it will have first GID 1. If tileset B consists of a region of numbers 20 to 29 then it will have first GID 20. And so on...   If in a Layer I have these tiles: 1, 10, 2, 20, 15, 25 Then they match this pattern of tilesets: A, A, A, B, A, B   What I really don't understand is how you can estimate in programming how this happens. I have looked at various TMX parsers but I can't figure out how exactly they achieve that.
  5. Hello, I have a piece of code where I would like to move the player up and down with touch input. If the touch is made just above the player position then player moves up and the same goes for opposite direction. The problem I have is that when the position of player is the same as the touch position then I have a nasty filckering (player moves up for one moment then moves down, and keep going as long as I have the pressed event going on). I tried to eliminate the flickering but I can't figure out what is going on. Any ideas or a better preffered way will be much welcomed. [CODE] public override void Update(GameTime gameTime) { #region Input NinjaGame.Instance.TouchCollection = TouchPanel.GetState(); foreach (TouchLocation tl in NinjaGame.Instance.TouchCollection) { if (tl.State == TouchLocationState.Pressed || tl.State == TouchLocationState.Moved) { float playerPosHalfHeight = this.Position.Y + (this.Texture.Height/2); // Something fishy is going on here... if (tl.Position.Y >= playerPosHalfHeight) this.Velocity = new Vector2(0f, 0.25f); if (tl.Position.Y < playerPosHalfHeight) this.Velocity = new Vector2(0f, -0.25f); } if (tl.State == TouchLocationState.Released) { this.Velocity = new Vector2(0f, 0f); } } #endregion base.Update(gameTime); /* In other words... float delta = (float)gameTime.ElapsedGameTime.Milliseconds; Position += new Vector2(Velocity.X * delta, Velocity.Y * delta); */ #region Screen bounds check (top / bottom) if (this.Position.Y + this.Texture.Height > NinjaGame.Instance.GraphicsDevice.Viewport.Height) this.Position = new Vector2(this.Position.X, NinjaGame.Instance.GraphicsDevice.Viewport.Height - this.Texture.Height); if (this.Position.Y < 0f) this.Position = new Vector2(this.Position.X, 0f); #endregion } [/CODE] Thanks, happy coding.
  6. [SlimDX] How to draw lines

    Thanks again man, I finally got some random lines with this code. [code] using System; using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; using SlimDX; using SlimDX.Direct3D9; namespace SlimDXGUI { class Program { public struct LineVertex { public Vector3 Position { get; set; } public int Color { get; set; } } public class Form1 : Form { Direct3D d3d; Device device; LineVertex[] lineData; VertexBuffer vertexBuffer; System.Timers.Timer timer = new System.Timers.Timer(); Random rnd = new Random(DateTime.Now.Millisecond); protected override void OnLoad(EventArgs e) { d3d = new Direct3D(); PresentParameters pp = new PresentParameters(); pp.SwapEffect = SwapEffect.Discard; pp.DeviceWindowHandle = Handle; pp.Windowed = true; pp.BackBufferWidth = Width; pp.BackBufferHeight = Height; pp.BackBufferFormat = Format.A8R8G8B8; device = new Device(d3d, 0, DeviceType.Hardware, Handle, CreateFlags.HardwareVertexProcessing, pp); lineData = new LineVertex[100]; for (int i = 0; i < lineData.Length; i++) { lineData[i] = new LineVertex(); lineData[i].Position = new Vector3(0f, 0f, 0f); Color c = Color.FromArgb( rnd.Next(1, 255), rnd.Next(1, 255), rnd.Next(1, 255)); lineData[i].Color = c.ToArgb(); } timer.Interval = 10; timer.Start(); timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); } void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { Render(); } protected override void OnClosed(EventArgs e) { device.Dispose(); d3d.Dispose(); } public void Render() { device.Clear(ClearFlags.Target, Color.White.ToArgb(), 0f, 1); for (int i = 0; i < lineData.Length; i++) { float x = (float) (rnd.NextDouble() * 2) - 1; float y = (float) (rnd.NextDouble() * 2) - 1; lineData[i].Position = new Vector3(x, y, 0f); } device.BeginScene(); device.VertexFormat = VertexFormat.Position | VertexFormat.Diffuse; device.DrawUserPrimitives<LineVertex>(PrimitiveType.LineList, 0, lineData.Length / 2, lineData); device.EndScene(); device.Present(); } } [STAThread] public static void Main(string[] args) { using (Form1 form = new Form1()) { Application.Run(form); } } } } [/code]
  7. VBO: How to draw many points

    Sorry guys, I was confused with example number 6. The triangle uses shaders for movement. http://ogldev.atspace.org/www/tutorial06/tutorial06.html
  8. [SlimDX] How to draw lines

    Unfortunately I don't understand much, but if could write a tutorial then I would be very happy.
  9. VBO: How to draw many points

    No, I want OpenGL 3 with VBO and Shaders, I know how to do it with OpenGL 1.5 but OpenGL 3 is less popular in this moment of speaking (that's why I am asking).
  10. Tao Framework

    Yep, I agree with Fetze (as I see you quoted my statement ) OpenTK is the future.
  11. Hi there, in this tutorial I learnt to draw a single point. http://ogldev.atspace.org/www/tutorial02/tutorial02.html Also in later lessons I learnt how to give motion to vertices. What I would like to do is to know how can I create a rain effect? [list=1][*]How to draw many points (raindrops)[*]How to know the speed of each raindrop.[*]How to know the bounds of lower and upper screen (inside the shader or outside in C++ code)?[/list]Any help will be much appreciated, thanks.
  12. I have started learning OpenGL 3.3 and 4.0 Very cool resources http://ogldev.atspace.org/ http://www.swiftless.com/opengltuts/opengl4tuts.html
  13. Collision Detection in C#

    Here's an example for tetris [url="http://www.codeproject.com/KB/cs/moemeka4.aspx"]http://www.codeproject.com/KB/cs/moemeka4.aspx[/url] not essentially "easy" to understand, as they say in computer science) but it's practical.
  14. Tao Framework

    Here, this works for me nicely. I use OpenTK mostly but TAO also suits. [code] using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using Tao.OpenGl; namespace TaoForm { public partial class MainForm : Form { public MainForm() { InitializeComponent(); } void MainFormLoad(object sender, EventArgs e) { simpleOpenGlControl1.InitializeContexts(); Gl.glClearColor(0.0f, 0.0f, 1.0f, 0.0f); // Blue Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Gl.glOrtho(0f, 1f, 0f, 1f, -1f, 1f); } void MainFormPaint(object sender, PaintEventArgs e) { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); Gl.glBegin(Gl.GL_TRIANGLES); Gl.glVertex2d(0.5, 1.0); Gl.glVertex2d(0.0, 0.0); Gl.glVertex2d(1.0, 0.0); Gl.glEnd(); Gl.glFlush(); } } } [/code]
  15. [SlimDX] How to draw lines

    Thanks for your answer unbird , I had look into it again and tried a few things. I made some changes but still no result. Here's what I did: [list=1][*]Studied the C++ edition (http://www.drunkenhyena.com/cgi-bin/view_cpp_article.pl?chapter=2;article=21)[*]Changed the struct name to [i]LineVertex[/i] and [i]data[/i] name to [i]lineData[/i].[*]LineVertex struct has a Vector4 for position instead of previously Vector3.[*]The Z Position of line is 1.0f (previously was 0.0f)[*]Made a change to DrawUserPrimitives method.[/list]Any opinions? If you have any ideas please post them because there are not enough resources on SlimDX, I do most of the learning from C++ codebase. [code] using System; using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; using SlimDX; using SlimDX.Direct3D9; namespace SlimDXGUI { class Program { public struct LineVertex { public Vector4 Position { get; set; } public int Color { get; set; } } public class Form1 : Form { Direct3D d3d; Device device; LineVertex[] lineData; VertexBuffer vertexBuffer; protected override void OnLoad(EventArgs e) { d3d = new Direct3D(); PresentParameters pp = new PresentParameters(); pp.SwapEffect = SwapEffect.Discard; pp.DeviceWindowHandle = Handle; pp.Windowed = true; pp.BackBufferWidth = Width; pp.BackBufferHeight = Height; pp.BackBufferFormat = Format.A8R8G8B8; device = new Device(d3d, 0, DeviceType.Hardware, Handle, CreateFlags.HardwareVertexProcessing, pp); lineData = new LineVertex[100]; Random rnd = new Random(DateTime.Now.Millisecond); for (int i = 0; i < lineData.Length; i++) { lineData[i] = new LineVertex(); float x = (float) rnd.Next(0, Width); float y = (float) rnd.Next(0, Height); float z = 1.0f; lineData[i].Position = new Vector4(x, y, z, 0f); lineData[i].Color = Color.FromArgb( (int)(rnd.NextDouble() % 255), (int)(rnd.NextDouble() % 255), (int)(rnd.NextDouble() % 255)).ToArgb(); } } protected override void OnClosed(EventArgs e) { device.Dispose(); d3d.Dispose(); } public void Render() { device.Clear(ClearFlags.Target, new Color4(Color.White), 1.0f, 0); device.BeginScene(); device.VertexFormat = VertexFormat.Position | VertexFormat.Diffuse; device.DrawUserPrimitives(PrimitiveType.LineList, Marshal.SizeOf(typeof(LineVertex)), lineData.Length / 2, lineData); device.EndScene(); device.Present(); } } [STAThread] public static void Main(string[] args) { using (Form1 form = new Form1()) { Application.Run(form); } } } } [/code]