C SDL2 Hello everyone I need to create the first draft of th

C++ SDL2

Hello everyone, I need to create the first draft of the AT-Robots game. I need to create a gray arena with black borders and with columns and rows on the right side which will containt three rectangles per each row with the information about the robots, like: health, name and color. For now I just need to design the arena with columns and rows with some random colors, names and health percentage. Here is a sample of how it should look like and here is my code so far.

const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
int main(int argc, char* argv[])
{
    SDL_Window* window = NULL;
    SDL_Renderer* renderer = NULL;
    SDL_Surface* screenSurface = NULL;

    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        printf(\"Could not initialize SDL. SDL_Error: %s\ \",SDL_GetError());
    }
    else
   {
       window = SDL_CreateWindow(\"SDL Test\",SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,SCREEN_WIDTH,SCREEN_HEIGHT,SDL_WINDOW_SHOWN);
       if (window==NULL) {
           printf(\"Cannot create window. SDL_Error: %s\ \",SDL_GetError());
       }
       else {
           SDL_Rect arect;
           screenSurface=SDL_GetWindowSurface(window);
           SDL_FillRect(screenSurface,NULL,SDL_MapRGB(screenSurface->format,0,0,0));
           arect.x=14; arect.y=14; arect.w=SCREEN_WIDTH-28; arect.h=SCREEN_HEIGHT-18;
           SDL_FillRect(screenSurface,&arect,SDL_MapRGB(screenSurface->format,128,128,128));
           SDL_RenderClear(renderer);

            SDL_SetRenderDrawColor(renderer, 66, 134, 244, SDL_ALPHA_OPAQUE);
            SDL_RenderDrawLine(renderer, 320, 200, 300, 240);
            SDL_RenderDrawLine(renderer, 300, 240, 340, 240);
            SDL_RenderDrawLine(renderer, 340, 240, 320, 200);
            SDL_RenderPresent(renderer);

           SDL_UpdateWindowSurface(window);
           SDL_Delay(3000);
       }

   }
   SDL_DestroyWindow(window);
    SDL_Quit();
    return 0;
}

Robot 1 Robot 2 Robot 3 Robot 4. 25% 41% 58% 99%

Solution

% Logistics Map % Classic chaos example. Plots semi-stable values of % x(n+1) = r*x(n)*(1-x(n)) as r increases to 4. % % Michael Hanchak, Dayton OH, USA, 2011 clear scale = 10000; % determines the level of rounding maxpoints = 200; % determines maximum values to plot N = 3000; % number of \"r\" values to simulate a = 2.0; % starting value of \"r\" b = 4; % final value of \"r\"... anything higher diverges. rs = linspace(a,b,N); % vector of \"r\" values M = 500; % number of iterations of logistics equation % Loop through the \"r\" values for j = 1:length(rs) r=rs(j); % get current \"r\" x=zeros(M,1); % allocate memory x(1) = 0.5; % initial condition (can be anything from 0 to 1) for i = 2:M, % iterate x(i) = r*x(i-1)*(1-x(i-1)); end % only save those unique, semi-stable values out{j} = unique(round(scale*x(end-maxpoints:end))); end % Rearrange cell array into a large n-by-2 vector for plotting data = []; for k = 1:length(rs) n = length(out{k}); data = [data; rs(k)*ones(n,1),out{k}]; end % Plot the data figure(97);clf h=plot(data(:,1),data(:,2)/scale,\'k.\'); set(h,\'markersize\',1) axis tight set(gca,\'units\',\'normalized\',\'position\',[0 0 1 1]) set(gcf,\'color\',\'white\') axis off
C++ SDL2 Hello everyone, I need to create the first draft of the AT-Robots game. I need to create a gray arena with black borders and with columns and rows on t
C++ SDL2 Hello everyone, I need to create the first draft of the AT-Robots game. I need to create a gray arena with black borders and with columns and rows on t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site