• Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Daichi

  • Rank
  1. So, I can get an instance of a C# class just fine to IronPython, but I can't seem to do much of anything with it's members or functions. Is there anyway to get around this problem? The IronPython documentation and my searches hasn't led me very far on figuring this out for the past several hours. Here is a simplified example of what I'm trying to do: [code]class Unit { public int HP { get; set; } public int Attack { get; set; } public Unit(int HP, int Attack) { this.HP = HP; this.Attack = Attack; } public void PointlessFunction() { } public override string ToString() { return "HP: " + HP.ToString() + " Attack: " + Attack.ToString(); } } class Program { static void Main(string[] args) { ScriptEngine Engine = Python.CreateEngine(); ScriptScope Scope = Engine.CreateScope(); Scope.SetVariable("Unit", DynamicHelpers.GetPythonTypeFromType(typeof(Unit))); // declare instance of Unit Engine.Execute("u = Unit(10,5)", Scope); // display Unit instance Engine.Execute("print u", Scope); //HP: 10 Attack: 5 // Try to change something Engine.Execute("u.HP = 20", Scope); //Unhandled Exception: System.MissingMemberException: 'Unit' object has no attribute 'HP' // Try to run a function Engine.Execute("u.PointlessFunction()", Scope); //Unhandled Exception: System.MissingMemberException: 'Unit' object has no attribute 'PointlessFunction' } }[/code]
  2. [XNA] 2D Flashlight Vision

    [quote name='remigius' timestamp='1307705269' post='4821671'] Does [url="http://www.catalinzima.com/2010/07/my-technique-for-the-shader-based-dynamic-2d-shadows/"]this tutorial[/url] help? [/quote] Do I actually need something this complicated? I don't necessarily need to cast light in all directions, just at a specific angle of view. heck, I don't even need to cast shadows, only a light overlay. I should also specify that I'm trying to target WP7, which I think has problems with custom shaders.
  3. [font="Calibri"][size="2"][font="arial, verdana, tahoma, sans-serif"][size="2"][font="Calibri"][size="2"][size="2"]Okay, so I have a simple 2D tile-based top-down game.[/size][/size][/font] [font="Calibri"][size="2"][size="2"]I have these guards that are trying to spot the player. They have a field of view that I want to represent as a flashlight glow that lights up the area. This area will be where the guard can see, so I'll also need to detect if the player is inside one of the guards' views. Tiles can also block their vision.[/size][/size][/font] [font="Calibri"][size="2"][size="2"]I guess I want something to look like this:[/size][/size][/font] [font="Calibri"][size="2"][size="2"][attachment=2975:flashlight_vision.png] [/size][/size][/font] [font="Calibri"][size="2"][size="2"]I've seen stuff about ray tracing or field of view, but I'm not sure where exactly to start first. [/size][/size][/font][/size][/font][/size][/font][img]http://public.gamedev.net/public/style_emoticons/default/mellow.gif[/img]
  4. XNA Small Solid Texture2D

    It seems to be TextureUsage now, but yeah. Thank you that did the trick. :D
  5. So, with XNA. Anyway to go about making a small solid Texture2D without loading an image? Like generate a 2x2 white image to use for drawing rectangles or whatever.
  6. 2d and 3d puzzle solvers

    I'm a little stumped right now, I'm having troubles figuring out how to locate a piece on the cube. Since I'm storing everything as a bunch of 2d arrays, They don't have any real relation to what pieces are connected. Cube So I need a lookup function, a way to identify a piece I'm looking for. Say I want to find the Red and White side cubie, I need a function to spit out faces 41 and 10 and have it tell me where they are located in my data array. //How my cube is stored int data[3][3][6]; for (z=0;z<6;z++) for (y=0;y<3;y++) for (x=0;x<3;x++) data[x][y][z] = i++; //How my colors are formed int color = int(value/9); //How the Z dimensions are laid out. //_ 4 //0 1 2 3 //_ 5 Once I can locate these cubies I can begin to move these little guys around to where they belong. Anyway, I'll keep trying. I think I might start by numbering all the cubies.
  7. 2d and 3d puzzle solvers

    Thanks everyone, It's going to be a bit of work for me to understand everything here. I'll take my time to try to figure it all out. I decided to go with Rockoon1's suggestion and go with 6 arrays for the cube. My test bed is in command line c++. It took me a while to write out all the transformations, but I think I figured it all out. Here is what I got so far. cube_test_01 2d test, with my cube display. Most of my transformations use a 2d rotation somewhere. cube_test_02 Rotate face. cube_test_03 Rotate top row. cube_test_05 Rotate right column up with different display. cube_test_06 Same as the last one, normal display. cube_test_07 Grid, from rotating the middle slice on each axis. I got the rotations currently in 3 functions. rotateFaceClockwise(int slice) rotateTopRowLeft(int slice) rotateRightColUp(int slice) I just tell it which of the 3 slices I want when I turn. Currently these rotations only work in one direction, so If I want to rotate right instead of left, I gotta use the turn left three times method. XD For now it gets the job done. Now I just got the hard part of telling it how to solve.
  8. Hi, I got two similar AI projects I'm working on. Trying to build a solver for a 2d sliding puzzle and a 3d Rubiks Cube. I'm trying to build these as what a human would solve like, so I don't need super efficiently. So, with both puzzles, most humans would solve First row, then work their way to the bottom. I assume with the 2d puzzle, I can use a 2d array to store everything. But how do I move the pieces toward the goal? And how do I deal with the last two rows, which can require a bit of shuffling. I have no idea the best method to store a Rubiks cube (I haven't done much 3d math). And also no idea how to handle the rotations of the cubelets (which I assume is going to be based on data structure I use. I know how to solve a cube with the basic algorithms, I just need a starting point. I assume there is some overlap on the theories between both.
  9. Um, Ok, using a pointer to the end() iterator works fine for containers where objects are only added to the end, like i'll be doing for Vector and in my case for a List. But can you go back over a Map? It's a sorted container, so the end could not be the last. (then again, like I said in my first post, I suppose I could just save the key when I add, since it's unique). Thanks for the help btw... I think most of my troubles are due to lack of sleep. I'm going to bed now. ^^; -Daichi
  10. I'd like to be able to get access to the last object I've added to my containers. Namely for a Vector, List or Map. For an STL Vector it seems like I can do *(myvector._Last-1) //for VC6 *(myvector._Mylast-1) //for VC.Net 2k3 I suppose for an STL Map, I could keep a copy of my Key when I add to my Map, but I'm sure there might be a more elegant way. And I'm clueless on an STL List. >.<; (Tho it should be simple.) It seems like I'm also going to have to keep track of my compiler versions too (or Maybe STL versions), since it seems to differ. I'm currently using MS compilers, so I care mostly about these options as of right now. -Daichi
  11. Great beginer c++ site

    I'd like to add the free ebook 'Thinking in Cpp 2nd Edition' by Bruce Eckel to the list. Worth buying a hard copy of this IMHO. -Daichi
  12. Yeah, I just figured that out, IntelliSence wasn't showing me the properties for a D3DXVECTOR3 object. Thanks a bunch, that was very helpful. Now I'll go relax for a bit. -Daichi :D
  13. Ah. I feel silly having to ask this, but how do I change my D3DXVECTOR3 pPosition? -Daichi :/
  14. Ok, I'm currently loading an 8x8 image Tilesheet of 128x128 pixel images into a IDirect3DTexture9. I'm trying to add functionality to my drawing routine for a mirrored tile image. I've read that I need to use Scaling and set the Axis I want to flip to -1.0. I'm not having much luck with this, It seems to be screwing with the position of how I grab my sprite on my Tilesheet texture. Do I need to subtract the image size somewhere? If so, How would I retrieve the texture size from the IDirect3DTexture9 object? Here is a tiny code fragment edited for easier reading. RECT Source = { _Tilex*TileWidth, _Tiley*TileHeight, _Tilex*TileWidth+TileWidth, _Tiley*TileHeight+TileHeight }; D3DXMATRIX transform; D3DXMatrixTransformation2D(&transform,NULL,NULL,&D3DXVECTOR2(-1, 1),NULL,NULL,NULL); pSprite->GetTransform(&transform); pSprite->Draw(pTexture, &Source, pCenter, pPosition, Color) -Daichi
  15. Is it safe to run my DX9 game loop in a separate thread from my message-pump? Here is what I got right now. My DX class is a global. Inside my WinMain: - initialize my DX class - start my Game loop thread - start a simple 'GetMessage' Message-pump Now this works find and dandy, but If I loose my d3ddevice, I'm unable to reset it and I get this message. Direct3D9: (ERROR) :Reset can only be called from the thread that the device was created from. And I get other errors if I try to create the d3ddevice within my game thread. I suppose I can go back to a single thread and using 'PeakMessage' instead but I was hoping to try some multithreading. -Daichi