Results 1 to 3 of 3

Thread: I'm getting strange error

  1. #1
    Serf
    Join Date
    May 2007
    Posts
    4

    Default I'm getting strange error

    I have started to make a sweeper-ish game, and so far i've only tried to draw the base grid, with empty squares mixed with bombed squares

    It compiles just fine, but it crashes when i start it for some strange reason, and i can't seem to find why...
    Here is my code:

    Code:
    #include <ClanLib/core.h>
    #include <ClanLib/application.h>
    #include <ClanLib/display.h>
    #define __Apple__
    #ifdef USE_SDL
    #include <ClanLib/sdl.h>
    #else
    #include <ClanLib/gl.h>
    #endif
    
    int grid[20][20];
    
    class Sweeper : public CL_ClanApplication
    {
    public:
    	virtual int main(int argc, char **argv)
    	{
    		CL_ConsoleWindow console("Console");
    		console.redirect_stdio();
    		quit = false;
    
    			srand((GLint)CL_System::get_time());
    			
    			for (int i = 0; i < 20;i++)
    			{
    				for (int j = 0; j < 20;j++)
    				{
    					if ((int)rand()%5 == 1)
    					{
    						grid[j][i] = 1;
    					}
    					else
    					{
    						grid[j][i] = 0;
    					}
    				}
    			}
    
    		try
    		{
    			CL_SetupCore setup_core;
    			CL_SetupDisplay setup_display;
    
    #ifdef USE_SDL
    			CL_SetupSDL setup_sdl;
    #else
    			CL_SetupGL setup_gl;
    #endif
    			CL_DisplayWindow window("Sweeper", 300, 300);
    			CL_Slot slot_quit = window.sig_window_close().connect(this, &Sweeper::on_window_close);
    
    			// Connect a keyboard handler to on_key_up()
    			CL_Slot slot_input_up = (window.get_ic()->get_keyboard()).sig_key_up().connect(this, &Sweeper::on_input_up);
    
    			CL_Surface bild_bomb("bomb.tga");
    			CL_Surface bild_empty("tom.tga");
    				
    			while (!quit)
    			{
    				CL_Display::clear(CL_Color(0,0,56));
    
    				//Draw:
    				for (int i = 0; i < 20;i++)
    				{
    					for (int j = 0; i < 20;j++)
    					{
    						if (grid[j][i] == 1)
    						{
    							bild_bomb.draw (15*j,15*i, window.get_gc());
    						}
    						else
    						{
    							bild_empty.draw (15*j, 15*i, window.get_gc());
    						}
    					}
    				}
    		
    				CL_Display::flip();
    				CL_System::keep_alive(10);
    			}
    		}
    		catch(CL_Error error)
    		{
    			std::cout << "Exception caught : " << error.message.c_str() << std::endl;			
    
    			// Display console close message and wait for a key
    			console.display_close_message();
    			return -1;
    		}
    		return 0;
    	}
    
    private:
    	bool quit;
    
    	void on_input_up(const CL_InputEvent &key)
    	{
    		if(key.id == CL_KEY_ESCAPE)
    		{
    			quit = true;
    		}
    	}
    
    	void on_window_close()
    	{
    		quit = true;
    	}
    } my_app;
    I am using visual studio 2005 and CL 0,8

    I have located that the problem is with the double for statments which attempts to draw, if i comment this part out it works just fine.

    Anyone who got any suggestions?

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,377

    Default

    Hmm, shouldn't the line:
    Code:
    for (int j = 0; i < 20;j++)
    be:
    Code:
    for (int j = 0; j < 20;j++)
    ?
    Seth A. Robinson
    Robinson Technologies

  3. #3
    Serf
    Join Date
    May 2007
    Posts
    4

    Default

    Ahh, i can't believe i missed something like that :S

    Thanks for the help

Similar Threads

  1. Integer strange error (for me)
    By andreaszdw in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 04-16-2007, 07:52 PM
  2. Strange scrolling bug in OSX version:
    By whisperstorm in forum Novashell Game Creation System
    Replies: 3
    Last Post: 03-22-2007, 05:20 AM
  3. Strange Bury Points
    By aGig in forum Funeral Quest
    Replies: 3
    Last Post: 02-02-2007, 04:26 AM
  4. Strange problems
    By File Sponge in forum Funeral Quest
    Replies: 4
    Last Post: 08-29-2004, 07:16 AM
  5. Strange static sound
    By tamaralynn in forum Dink Smallwood HD
    Replies: 1
    Last Post: 11-22-2003, 02:32 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •