All pastes #110952 Raw Edit

Mine

public text v1 · immutable
·published 2006-08-02 01:28 UTC
rendered paste body
using System;
using ManagedHGE;

namespace Redone
{
	/// <summary>
	/// Description of Game.
	/// </summary>
	/// 
	public class MainClass
	{
		static void Main()
		{
			Game game = new Game();
		}
	}
	public class Game
	{
		
	        public HGE hge;
          //  static Font font;
            
            private float t;
            private Random rand = new Random(); 
            private int map_size=40;
			public int[,] map;  //= new int[map_size,map_size];
			private Color col = new Color(255,255,255,1);
			private Color bg_color = new Color(1,1,1,1);
			public Color black = new Color(0,0,0,1);
			private int ofx = 300, ofy = 100;
			private Font fnt = new Font("font1.fnt");
			
			
		public Game()
		{
			hge = HGECreator.GetHGE();
            hge.System.FrameFunc = FrameFunc;
            hge.System.Windowed = true;
            hge.System.Title = "HGE Tutorial";
            map = new int[map_size,map_size];
            if( hge.System.Initiate() )
            {
                    //font = new Font( "font1.fnt" );
                    HandleTexture tex = hge.Texture.Load( "C:/game graphics/flag/grass.png" );
                    if( tex.handle == 0 )
                    { }//can't load
                    
                    for(int xc = 0; xc < map_size; xc ++)
                    	for(int yc = 0; yc < map_size; yc ++)
                    		map[xc,yc] = rand.Next(0,2);
                    
                    hge.System.Start();
            }
            else
            {
                   // error
                    hge.System.GetErrorMessage();
            }
		}
		
		public void FrameFunc(Object o, FrameArgs frame_args)
        {
                if (hge.Input.GetKeyState(KeyCode.ESCAPE))
                {
                        frame_args.exit = true;
                }
                

                t += hge.Timer.GetDelta();

                hge.Gfx.BeginScene();
                hge.Gfx.Clear(bg_color);
                
                
                
                for(int xc = 0; xc < map_size; xc ++)
                {
                	for(int yc = 0; yc < map_size; yc ++)
                	    {
                		
                		if (map[xc,yc] == 0)
                	    	{
                	    		 col.r = 1;
                	    		 col.g = 1;
                	    		 col.b = 1;
                			}
                	    	else
                	    	{
                	    		 col.r = 0;
                	    		 col.g = 0;
                	    		 col.b = 0;
                	    	}
                	    	DrawRect((xc * 10)+ofx, (yc * 10)+ofy, 10, 10,col,true);
                	    	//hge.Gfx.RenderLine(0,0,800,600,Color.Black,1);
                	    }
                }
						DrawRect(ofx,ofy,400,400,black,false);
						
                fnt.Render(10, 10, "FPS: " + hge.Timer.GetFPS(), Align.LEFT);
                hge.Gfx.EndScene();
        }
	
		private void DrawRect(int x, int y, int w, int h,Color col,bool filled)
        {
        	if(filled)
        	{
            	Quad quad = new Quad();
            	
            	quad.v0.x = x;
            	quad.v0.y = y;
            	quad.v0.col = col;
            		
            	quad.v1.x = x + w;
            	quad.v1.y = y;
            	quad.v1.col = col;
            		
            	quad.v2.x = x + w;
            	quad.v2.y = y + h;
            	quad.v2.col = col;
            		
            	quad.v3.x = x;
            	quad.v3.y = y + h;
            	quad.v3.col = col;
            		
            	hge.Gfx.RenderQuad(quad);
        	}
        	else if(filled != true)
            {
            	hge.Gfx.RenderLine(x,y,x+w,y,col,1);
            	hge.Gfx.RenderLine(x+w,y,x+w,y+h,col,1);
            	hge.Gfx.RenderLine(x+w,y+h,x,y+h,col,1);
            	hge.Gfx.RenderLine(x,y,x,y+h,col,1);
            }
    
        }
	
	}
	
	
}