if player reaches end of background(coordinates) show Mission Accomplished

Okay so what I am trying to do is in DirectX C++. basically I've got a character moving across the screen and a background that moves as you do(scrolls as player walks) I am wondering how I make a victory condition for when the player reaches the end of the picture(Background) idk if I need to use coordinates or if I can just set the end of the picture to have Mission Accomplished as you cross into the void of emptiness, lol. Thanks in advance for any help.
here is MyGame.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include "MyDirectX.h"
#include "Timer.h"
using namespace std;

const string APPTITLE = "E.V.I.L.";
const int SCREENW = 800;
const int SCREENH = 597;
string player_state;
bool playerJumping = false;

Timer timer;

LPDIRECT3DTEXTURE9 background = NULL;
LPDIRECT3DTEXTURE9 player = NULL;
LPDIRECT3DTEXTURE9 bullets = NULL;
SPRITE playerSprite;
SPRITE Background;
SPRITE Bullets;

D3DCOLOR color = D3DCOLOR_ARGB(0, 255, 255, 255);

//CSound *sound_bounce = NULL;
DWORD screentimer = timeGetTime();

bool Game_Init(HWND window)
{
    srand(time(NULL));

    //initialize Direct3D
    if (!Direct3D_Init(window, SCREENW, SCREENH, false))
    {   MessageBox(window,"Error initializing Direct3D",APPTITLE.c_str(),0);
        return false;}

    //initialize DirectInput
    if (!DirectInput_Init(window))
    {   MessageBox(window,"Error initializing DirectInput",APPTITLE.c_str(),0);
        return false;}

    //initialize DirectSound
    if (!DirectSound_Init(window))
    {   MessageBox(window,"Error initializing DirectSound",APPTITLE.c_str(),0);
        return false;}


    //load the background image
    background = LoadTexture("Assets/firstlevel.png");
    if (!background) 
    {   MessageBox(window,"Error loading background.png",APPTITLE.c_str(),0);
        return false;}

    player = LoadTexture("Assets/player1walking.png");
    if (!player) 
    {   MessageBox(window,"Error loading player1.png",APPTITLE.c_str(),0);
        return false;}

    bullets = LoadTexture("Assets/bullet.png");
        if (!bullets) 
    {   MessageBox(window,"Error loading bullet.png",APPTITLE.c_str(),0);
        return false;}

    playerSprite.columns = 8;
    playerSprite.endframe = 8;
    playerSprite.height = 44;
    playerSprite.width = 52;
    playerSprite.x = 350;
    playerSprite.y = 400;
    playerSprite.scaling = 2.0f;

    Background.height = 600;
    Background.width = 16676;

    Bullets.height = 5;
    Bullets.width = 5;

    return true;
}

void Game_Run(HWND window)
{
    if (!d3ddev) return;
    DirectInput_Update();
    d3ddev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,100), 1.0f, 0);

    /*
     * slow rendering to approximately 60 fps
     */
    timer.LockFPS(60);
    {
        screentimer = GetTickCount();
    
        //detect moveing right or left
        if (Key_Down(DIK_LEFT) || Key_Down(DIK_A))
        {
            player_state = "walkingLeft";
            playerSprite.velx = 0.5;
        }
        else if (Key_Down(DIK_RIGHT) || Key_Down(DIK_D))
        {
            player_state = "walkingRight";
            playerSprite.velx = -0.5;
        }
        if (Key_Down(DIK_SPACE))
        {
            Bullets.x = Bullets.y = playerSprite.x = playerSprite.y;
            Bullets.velx = 0.5;
        }
        else player_state = "standing";
        //detect jump
        if (Key_Down(DIK_UP)){
            playerJumping = true;
        }else playerJumping = false;

        //if jumping, jump
        if (playerJumping) playerSprite.vely = -1;

        //if not then fall to ground
        if (!playerJumping && playerSprite.y < 400) playerSprite.vely = 1;
        else if (!playerJumping) playerSprite.vely = 0;
    
        //move and reset
        Background.x += playerSprite.velx;
        playerSprite.y += playerSprite.vely;
        playerSprite.velx = 0;

        //start rendering
        if (d3ddev->BeginScene())
        {
            //start sprite handler
            spriteobj->Begin(D3DXSPRITE_ALPHABLEND);

            //draw background
            Background.Draw(background);
            playerSprite.Draw(player);
            Bullets.Draw(bullets);

            //stop drawing
            spriteobj->End();

            //stop rendering
            d3ddev->EndScene();
            d3ddev->Present(NULL, NULL, NULL, NULL);
        }
    }

    //exit with escape key or controller Back button
    if (KEY_DOWN(VK_ESCAPE)) gameover = true;
}

void Game_End()
{
    if (background) background->Release();
    if (player) player->Release();
    if (bullets) bullets->Release();

    DirectSound_Shutdown();
    DirectInput_Shutdown();
    Direct3D_Shutdown();
}
Topic archived. No new replies allowed.