Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2D Physics Engine Help
#8
Quote:@Terry -  The Library is written in C++ and I figured by using DECLARE LIBRARY I could get this done. However, my C++ knowledge is lacking as well. Trying to figure out where pointers are used versus variables, . . .
@Terry - just in case you want to try something like this, pointers are created like this in C/C++:

int *zgr, **zzgr; (**zzgr is a pointer to a pointer. Yes, you can do that in C, ad nauseam.)

Here is an old example program that flips a number and a character array. - With zzgr = &zgr the pointer-to-pointer is assigned the address of zgr. The pointer then moves backwards through the field (zgr--), and **zzgr displays it. Hope that's halfway understandable.

Code: (Select All)
#include <stdio.h>
#include <stdlib.h>

#define MAX 9

int main(void)
{
  int feld[] = { 1,2,3,4,5,6,7,8,9 };
  char char_feld[] = { 'a','b','c','d','e','f','g','h','z' };
  int i, *zgr,  **zzgr;
  char *char_zgr, **cchar_zgr;

  for ( i = 0; i < MAX; i++ )
  {
      zgr = &feld[i];
      printf("%d ", *zgr);
  }
  printf("\t");
    
  for ( i = 0; i < MAX; i++ )
  {
      char_zgr = &char_feld[i];
      printf("%c ", *char_zgr);
  } 
    printf("\n\n");
    
    //Mit zzgr = &zgr wird dem Zeiger-auf-Zeiger die Adresse
    //von zgr zugewiesen. Der Zeiger zgr geht dann rückwärtz
    //das Feld durch (zgr--), und **zzgr läßt es anzeigen.
  for ( i = 0;  i < MAX; i++ )
  {
      zzgr = &zgr;
      printf("%d ",**zzgr);
      zgr--;
  }
  printf("\t");
    
  for ( i = 0; i < MAX; i++ )
  {
      cchar_zgr = &char_zgr;
      printf("%c ", **cchar_zgr);
      char_zgr--;
  }
    return(0);
}

If you want to compile the program yourself, it says in the screenshot.

[Image: zgr-auf-zgr-2023-06-13.jpg]
Reply


Messages In This Thread
2D Physics Engine Help - by TerryRitchie - 06-12-2023, 03:16 PM
RE: 2D Physics Engine Help - by a740g - 06-12-2023, 03:35 PM
RE: 2D Physics Engine Help - by madscijr - 06-12-2023, 04:11 PM
RE: 2D Physics Engine Help - by Ultraman - 06-12-2023, 04:30 PM
RE: 2D Physics Engine Help - by a740g - 06-12-2023, 05:22 PM
RE: 2D Physics Engine Help - by justsomeguy - 06-12-2023, 09:34 PM
RE: 2D Physics Engine Help - by justsomeguy - 06-12-2023, 09:36 PM
RE: 2D Physics Engine Help - by TerryRitchie - 06-16-2023, 02:25 PM
RE: 2D Physics Engine Help - by Kernelpanic - 06-12-2023, 11:11 PM
RE: 2D Physics Engine Help - by Sprezzo - 06-13-2023, 02:13 AM
RE: 2D Physics Engine Help - by justsomeguy - 06-15-2023, 03:43 AM
RE: 2D Physics Engine Help - by TerryRitchie - 06-15-2023, 05:08 AM



Users browsing this thread: 4 Guest(s)