Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

JossBoss

Treue Seele

  • »JossBoss« ist der Autor dieses Themas

Beiträge: 182

Wohnort: Luxemburg

  • Private Nachricht senden

1

30.06.2006, 16:36

Sehe den Ball nicht.,..

hier der code:
kann da vielleicht jemand sehen weshalb gameover immer sofort nach dem spielstart true ist?? (deshalb seh ich den ball nicht... glaucb ich zumindest...) es ist nicht alles was grün ist auskommentiert ;-) und der code is auch noch lang nich fertig

ich hab grad gemerkt, dass die variable fT immer null ist... das hat auch 100 pro was damit zu tun... wieso könnte sie 0 sein?

C-/C++-Quelltext

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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
#include "Crashball.h"

//Definition der Init-Methode

tbResult CGame::Init()
{
    Load();

    return TB_OK;
}

//Definition der Exit-Methode

tbResult CGame::Exit()
{
    Unload();

    return TB_OK;
}

//Definition der Load-Methode

tbResult CGame::Load()
{
//  char cBlockName[64];


    m_pLevelModel  = new tbModel;
    m_pPaddleModel = new tbModel;
    m_pBallModel   = new tbModel;
//  m_pBulletModel = new tbModel;

    
/*  for(int i=0; i<4; i++)
    {
        m_pBlockModel[i] = new tbModel;
    }
*/
    m_pLevelModel->Init("Data\\Level.tbm","Data\\");
    m_pPaddleModel->Init("Data\\Paddle.tbm","Data\\");
    m_pBallModel->Init("Data\\Ball.tbm","Data\\");
    //m_pBulletModel->Init("Data\\Shot.tbm","Data\\");


    /*for(int iB=0; iB<3; iB++)
    {
        sprintf(cBlockName,"Data\\Block%d.tbm",iB+1);
        m_pBlockModel[iB]->Init(cBlockName,"Data\\");
    }*/

    for(int iBall = 0; iBall < 16; iBall++)
    {
        m_cBall[iBall] = new CBall;
    }

    /*for(int iBlock = 0; iBlock < 32; iBlock++)
    {
        m_cBlock[iBall] = new CBlock;
    }*/

    //InitLevel(1);

    m_pCube = tbTextureManager::Instance().GetCubeTexture("Data\\skybox.dds");
    m_sBox.Init(m_pCube);

    CreateBall(tbVector3(0.0f, 5.0f, 0.25f), tbVector3(0.0f), true);

    m_vPaddlePos = tbVector3(0.0f, 0.0f, -8.0f);

    m_iBulletTime = 0;
    m_bGameOver = false;
    m_iLevel = 0;
    m_iLives = 5;
    m_iScore = 0;
    m_bPause = false;


    return TB_OK;
}

//Definition der Unload-Methode

tbResult CGame::Unload()
{
    TB_SAFE_DELETE(m_pLevelModel);
    TB_SAFE_DELETE(m_pPaddleModel);
    TB_SAFE_DELETE(m_pBallModel);
    //TB_SAFE_DELETE(m_pBulletModel);


/*  for(int i=0; i<4; i++)
    {
        TB_SAFE_DELETE(m_pBlockModel[i]);
    }
*/
    for(int iBall = 0; iBall < 16; iBall++)
    {
        TB_SAFE_DELETE(m_cBall[iBall]);
    }

    /*for(int iBlock = 0; iBlock < 32; iBlock++)
    {
        TB_SAFE_DELETE(m_cBlock[iBall]);
    }*/

    m_sBox.Exit();

    return TB_OK;
}

//Definition der Move-Methode

tbResult CGame::Move(float fT)
{
   int iBallNum  = 0;
   //int iBlockNum = 0;


   if(WasButtonPressed(TB_KEY_P) || WasButtonPressed(TB_KEY_PAUSE))
   {
       m_bPause = !m_bPause;
       g_pCrashball->m_pSound[5]->PlayNextBuffer();
   }

   if(m_bPause == true)
   {
       return TB_OK;
   }

    m_vPaddleVel.x = m_vPaddlePos.x += g_pbButtons[TB_KEY_RIGHT] * 30.0f * fT;
    m_vPaddleVel.x = m_vPaddlePos.x -= g_pbButtons[TB_KEY_LEFT] * 30.0f * fT;
    //m_vPaddleVel.z = m_vPaddlePos.z += g_pbButtons[TB_KEY_UP] * 10.0f * fT;

    //m_vPaddleVel.z = m_vPaddlePos.z -= g_pbButtons[TB_KEY_DOWN] * 10.0f * fT;

 
   if(m_vPaddlePos.x - 1.0f <= -10.0f)
   {
       m_vPaddlePos.x  = -9.0f;
   }

   if(m_vPaddlePos.x + 1.0f >= 10.0f)
   {
       m_vPaddlePos.x  = 9.0f;
   }


   /*if(m_vPaddlePos.z >= -8.0f)
   {
       m_vPaddlePos.z  = -8.0f;
   }

   if(m_vPaddlePos.z <= -10.0f)
   {
       m_vPaddlePos.z  = -10.0f;
   }
*/
   for(int iBall=0; iBall<16; iBall++)
   {
       if(m_cBall[iBall]->m_bExists == true)
       {    
           iBallNum++;
           m_cBall[iBall]->Move(fT);
          
       }
   }

   m_iScore = iBallNum;
   if(iBallNum == 0)
   {
       if(m_iLives == 0)
       { 
           m_bGameOver = true;
       }
       else
       {
           m_iLives--; 
           g_pCrashball->m_pSound[3]->PlayNextBuffer();
           CreateBall(tbVector3(0.0f,0.0f,0.25f), tbVector3(0.0f), true);
       }
   }

   if(m_bGameOver == true)
   {
       g_pCrashball->m_pSound[2]->Play(0);
   }

   if(g_pbButtons[TB_KEY_SPACE] && m_cBall[0]->m_bExists && m_cBall[0]->m_bGrabbed)
   {
       g_pCrashball->m_pSound[0]->PlayNextBuffer();

       m_cBall[0]->m_bGrabbed   = false;

       m_cBall[0]->m_vPosition += m_vPaddlePos;

       m_cBall[0]->m_vVelocity.x = tbFloatRandom(-2.0f,2.0f);
       m_cBall[0]->m_vVelocity.y = 0.0f;
       m_cBall[0]->m_vVelocity.z = tbFloatRandom(9.0f,10.0f);

       m_cBall[0]->m_vVelocity  += m_vPaddleVel;
   }

  /* for(int iBlock=0; iBlock<32; iBlock++)
   {
       if(m_cBlock[iBlock]->m_iEnergy > 0) { iBlockNum++;}
   }

   if(iBlockNum == 0)
   {
       m_iScore += 2000 + int(1000000.0f * (1.0f/m_fLevelTime));

       m_iLevel++;

       if(m_iLevel > 10) m_iLevel = 1;

       InitLevel(m_iLevel);

       tbDelay(200);
   }
*/

  if(WasButtonPressed(TB_KEY_S))
  {   
      m_bSloMo = !m_bSloMo;
  }

   if(WasButtonPressed(TB_KEY_ESCAPE))
   {
       g_pCrashball->m_pSound[5]->PlayNextBuffer();
       g_pCrashball->SetGS(GS_MENU);
   }

   m_fLevelTime += fT;

   return TB_OK;
}
      
//Definition der Render-Methode

tbResult CGame::Render(float fT)
{
    tbMatrix   mProjection;
    tbMatrix   mCamera;
    tbVector3  vCameraPos;
    tbVector3  vCameraLookAt;
    D3DLIGHT9  lLight;
    D3DLIGHT9  lSloMo;
    char       cText[512];

    tbDirect3D &D3D = tbDirect3D::Instance();

    D3D->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, tbColor(0.0f, 0.0f, 0.0f), 1.0f, 0);
    D3D->BeginScene();

    vCameraPos   = m_vPaddlePos+tbVector3(0.0f, 14.0f, -8.0f);
    vCameraLookAt = m_vPaddlePos * 0.4f;

    mCamera = tbMatrixCamera(vCameraPos, vCameraLookAt);

   
    D3D.SetTransform(D3DTS_VIEW, mCamera);

    mProjection = tbMatrixProjection(TB_DEG_TO_RAD(60.0f),
                                     D3D.GetAspect(),
                                     0.0f,
                                     35.0f);

    D3D.SetTransform(D3DTS_PROJECTION, mProjection);

    ZeroMemory(&lLight, sizeof(D3DLIGHT9));
    lLight.Type      = D3DLIGHT_DIRECTIONAL;
    lLight.Diffuse   = tbColor(1.0f);
    lLight.Ambient   = tbColor(1.0f, 1.0f, 1.0f);
    lLight.Specular  = tbColor(1.0f, 1.0f, 1.0f);
    lLight.Direction = -vCameraLookAt;
    D3D->SetLight(0, &lLight);
    D3D->LightEnable(0, true);

    ZeroMemory(&lSloMo, sizeof(D3DLIGHT9));
    lSloMo.Type      = D3DLIGHT_DIRECTIONAL;
    lSloMo.Diffuse   = tbColor(1.0f, 0.50f, 0.0f);
    lSloMo.Ambient   = tbColor(0.0f, 0.9f, 0.4f);
    lSloMo.Specular  = tbColor(1.0f, 0.50f, 0.0f);
    lSloMo.Direction = -vCameraLookAt;
    D3D->SetLight(1, &lSloMo);

    m_sBox.Render(vCameraPos);

    D3D.SetTransform(D3DTS_WORLD, tbMatrixIdentity());
    m_pLevelModel->Render();

    D3D.SetTransform(D3DTS_WORLD, tbMatrixTranslation(m_vPaddlePos));
    m_pPaddleModel->Render();
    
    /*for(int iBlock=0; iBlock<32; iBlock++)
    {
      if(m_cBlock[iBlock]->m_iEnergy>0)
      {
          m_cBlock[iBlock]->Render(fT);
      }
    }
*/
    for(int iBall=0; iBall<16; iBall++)
    {
        if(m_cBall[iBall]->m_bExists == true)
        {
            m_cBall[iBall]->Render(fT);
        }
    }


    if(m_bSloMo == true)
    {
      D3D->LightEnable(0, false);
      D3D->LightEnable(1, true);
    }
    else
    {
    D3D->LightEnable(1, false);
    }

    g_pCrashball->m_pFont->Begin();
    
    sprintf(cText, "Score: %d", m_iScore);
    g_pCrashball->m_pFont->DrawText(tbVector2(0.05f, 0.05f),
                                cText,
                                TB_FF_RELATIVE | TB_FF_RELATIVESCALING, 
                                -1,
                                tbColor(0.9f, 0.2f, 0.0f));

    sprintf(cText, "Lives: %d", m_iLives);
    g_pCrashball->m_pFont->DrawText(tbVector2(0.05f, 0.1f),
                                cText,
                                TB_FF_RELATIVE | TB_FF_RELATIVESCALING, 
                                -1,
                                tbColor(0.9f, 0.2f, 0.0f));

    sprintf(cText, "BulletTime: %d", m_iBulletTime);
    g_pCrashball->m_pFont->DrawText(tbVector2(0.05f, 0.15f),
                                cText,
                                TB_FF_RELATIVE | TB_FF_RELATIVESCALING, 
                                -1,
                                tbColor(0.9f, 0.2f, 0.0f));

    sprintf(cText, "Level: %d", m_iLevel);
    g_pCrashball->m_pFont->DrawText(tbVector2(0.05f, 0.2f),
                                cText,
                                TB_FF_RELATIVE | TB_FF_RELATIVESCALING, 
                                -1, 
                                tbColor(0.9f, 0.2f, 0.0f));

    if(m_bPause == true)
    {
      g_pCrashball->m_pFont->DrawText(tbVector2(0.5f, 0.5f),
                                "Pause",
                                TB_FF_ALIGN_HCENTER | TB_FF_ALIGN_VCENTER | TB_FF_RELATIVE | TB_FF_RELATIVESCALING, 
                                -1,
                                tbColor(1.0f, 0.0f, 0.0f));
    }

    if(m_bGameOver == true)
    {
      g_pCrashball->m_pFont->DrawText(tbVector2(0.5f, 0.5f)+cosf(g_pCrashball->m_fTime*900)/900,
                                "Game Over!!",
                                TB_FF_ALIGN_HCENTER | TB_FF_ALIGN_VCENTER | TB_FF_RELATIVE | TB_FF_RELATIVESCALING, 
                                -1,
                                tbColor(1.0f, 0.0f, 0.0f));
    }

    g_pCrashball->m_pFont->End();

    D3D->EndScene();

  return TB_OK;
}

int CGame::CreateBall(tbVector3 vPosition,
                      tbVector3 vVelocity,
                      bool bgrabbed)
{
    for(int iBall=0; iBall<16; iBall++)
    {
        if(m_cBall[iBall]->m_bExists == false)
        {
            m_cBall[iBall]->m_bExists   = true;
            m_cBall[iBall]->m_bGrabbed  = bgrabbed;
            m_cBall[iBall]->m_vPosition = vPosition;
            m_cBall[iBall]->m_vVelocity = vVelocity;
            m_cBall[iBall]->m_pGame     = this;
            
            return iBall;
        }
    }
    
    return -1;
}


THX & MFG!! 8) 8)
Gratis Tools+Software und Games:

www.miraculous.eu.tc

BlackSnake

Community-Fossil

Beiträge: 1 549

Beruf: Student

  • Private Nachricht senden

2

30.06.2006, 16:54

Re: Sehe den Ball nicht.,..

Zitat von »"JossBoss"«

hier der code:
(deshalb seh ich den ball nicht... glaucb ich zumindest...)


man soll nicht glauben sondern wissen.

kann sein das du die modelle gar nicht lädst (nur ne idee neben bei, als ich mir den code angeschaut habe)

JossBoss

Treue Seele

  • »JossBoss« ist der Autor dieses Themas

Beiträge: 182

Wohnort: Luxemburg

  • Private Nachricht senden

3

30.06.2006, 16:58

nee is gemacht... is bloss wegen der fT sicher...
Gratis Tools+Software und Games:

www.miraculous.eu.tc

BlackSnake

Community-Fossil

Beiträge: 1 549

Beruf: Student

  • Private Nachricht senden

4

30.06.2006, 18:34

hm...

pack die initialisierungen mal in die init() methode und nicht in die load() methode.

dann sollte es eigentlich gehen :idea:

JossBoss

Treue Seele

  • »JossBoss« ist der Autor dieses Themas

Beiträge: 182

Wohnort: Luxemburg

  • Private Nachricht senden

5

01.07.2006, 09:33

ok es geht jetzt.. musste einen konstruktor in der ball klasse einfügen...
aber, der ball stockt immer wenn er fliegt, und wechselt immer seine flugbahn, obwohl ich ihm die gar nicht angegeben habe...

was ist das??
Gratis Tools+Software und Games:

www.miraculous.eu.tc

JossBoss

Treue Seele

  • »JossBoss« ist der Autor dieses Themas

Beiträge: 182

Wohnort: Luxemburg

  • Private Nachricht senden

6

02.07.2006, 20:52

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
if(g_pbButtons[TB_KEY_SPACE] && m_cBall[0]->m_bExists && m_cBall[0]->m_bGrabbed)
   {
       g_pCrashball->m_pSound[0]->PlayNextBuffer();

       m_cBall[0]->m_bGrabbed   = false;

       m_cBall[0]->m_vPosition += m_vPaddlePos;

       m_cBall[0]->m_vVelocity.x = tbFloatRandom(-2.0f,2.0f);
       m_cBall[0]->m_vVelocity.y = 0.0f;
       m_cBall[0]->m_vVelocity.z = tbFloatRandom(9.0f,10.0f);

       m_cBall[0]->m_vVelocity  += m_vPaddleVel;
   } 


Dieser teil bhockt bei mir... der ball stockt immer wenn er fliegt, und wechselt immer seine flugbahn, obwohl ich ihm die gar nicht angegeben habe und auch wenn er nirgends gegen knallt

mfg & thx!!
Gratis Tools+Software und Games:

www.miraculous.eu.tc

Werbeanzeige