Thread: GDI polygon problom(i think im gonna kill my compiler iif i dont work this out)

  1. #1
    Registered User PanzTec's Avatar
    Join Date
    Sep 2004
    Posts
    24

    GDI polygon problom(i think im gonna kill my compiler iif i dont work this out)

    ok i have a problom... can some one please help me and tell me whats wrong be for i kill the thing.... and could you also tell me how to stop this happning again... thanks ppl

    Code:
    #include "Game.h"
    #include <stdlib.h>
    #include <time.h>
    #include <stdio.h>
    #include <math.h>
    #include <string.h>
    
    #define WINDOW_WIDTH    640
    #define WINDOW_HEIGHT   480
    
    struct Points
    {
    	long y;
    	long x;
    };
    
    Points points[7];
    
    void engine::Game_Main(HWND hwnd)
    {
    	
    	HDC         hdc;
    
    	hdc = GetDC(hwnd);
    	///backround
    	HBRUSH black = CreateSolidBrush(RGB(0,0,0));
    	SelectObject(hdc,black);
    	RECT rect;
    	// create a rectangle
        rect.left   = 0;
        rect.top    = 0;
        rect.right  = 1000;
        rect.bottom = 1000;
    	FillRect(hdc,&rect,black);
    	DeleteObject(black);
    
    
    
    	//end of backround
    	 SetTextColor(hdc, RGB(100,0,255));
    	TextOut(hdc,250,0, "Movment Test", strlen("Movment Test"));
    
    	TextOut(hdc,0,435,"PanzTec Games.co   -   http://www.panrix.org", strlen("PanzTec Games.co   -   http://www.panrix.org"));
    	
    	
    	ReleaseDC(hwnd, hdc);
    
    
    }
    
    
    
    void engine::ball_prog(HWND hwnd)
    {
    	HDC hdc;
    	hdc = GetDC(hwnd);
    	HBRUSH black = CreateSolidBrush(RGB(0,100,150));
    	SelectObject(hdc,black);
    	HPEN green_pen = CreatePen(PS_SOLID, 3,RGB(50,0,200));	
    	HPEN old_pen = (HPEN)SelectObject(hdc, green_pen);
    	balltx += aclx;
    	ballbx += aclx;
    	ballty += acly;
    	ballby += acly;
    	if(ballbx > 639)
    	{
    		aclx = -2;
    	}
    	if(ballby > 450)
    	{
    		acly = -2;
    	}
    	if(ballty < 1)
    	{
    		acly = 2;
    	}
    	if(balltx < 1)
    	{
    		aclx = 2;
    	}
    	Ellipse(hdc,balltx,ballty,ballbx,ballby);
    	//Polygon(hdc, poly[], pointp);
    
    	int points_count = 7;
    	Polygon(hdc , points , points_count);
    
    	SelectObject(hdc, old_pen);
    	DeleteObject(green_pen);
    	DeleteObject(old_pen);
    	ReleaseDC(hwnd, hdc);
    
    
    }
    
     engine::engine()
    {
    
    
    }
    engine::~engine()
    {
    
    }
    
    
    void engine::start()
    {
    	int i = 6;
    	while( --i <= 0)
    	{
    		points.y[i] = rand()%500;
    		points.x[i] = rand()%300;
    	}
    
    	acly = 2;
    	aclx = 2;
    	balltx = 300;
    	ballbx = 350;
    	ballty = 300;
    	ballby = 350;
    }
    this is my error
    Code:
    --------------------Configuration: new windows - Win32 Debug--------------------
    Compiling...
    Game.cpp
    d:\ufs\coding\main game\new windows\game.cpp(85) : error C2664: 'Polygon' : cannot convert parameter 2 from 'struct Points [7]' to 'const struct tagPOINT *'
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    d:\ufs\coding\main game\new windows\game.cpp(111) : error C2228: left of '.y' must have class/struct/union type
    d:\ufs\coding\main game\new windows\game.cpp(112) : error C2228: left of '.x' must have class/struct/union type
    Error executing cl.exe.
    
    new windows.exe - 3 error(s), 0 warning(s)
    The Matrix Will Live Again!

  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    I can't give you a solid answer without seeing the function prototype for Polygon(), however, I can confidently say that the second parameter is not be set up correctly to do what you want.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    The polygon function does not take an array of struct Points, it takes an array of POINT structures. This structure is defined by including <windows.h>.

    So change this:
    Code:
    Points points[7];
    to this:
    Code:
    POINT points[7];
    Also, this:
    Code:
        int i = 6;
        while( --i <= 0)
        {
            points.y[i] = rand()%500;
            points.x[i] = rand()%300;
        }
    should be:
    Code:
        for (int i = 0; i < 7; i++)
        {
            points[i].y = rand()%500;
            points[i].x = rand()%300;
        }

  4. #4
    Registered User PanzTec's Avatar
    Join Date
    Sep 2004
    Posts
    24
    Thank you so very much. I thought I was gonna go nuts...
    The Matrix Will Live Again!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I can't get this new compiler to work.
    By Loduwijk in forum C++ Programming
    Replies: 7
    Last Post: 03-29-2006, 06:42 AM