My Newest and Biggest project

so I am working on a big project called “Dump truck SImulator”. If you have played a simulator game on Roblox, then you know what this will be like. I Just started on it today and would like some help, but I won’t ask for direct code, just Ideas with examples on how to put them in.
here it is so far:
Truck: ``

class Truck {
//positioning
int x, y;
//wether the hopper is up
boolean hopperUp;
//move the truck
void move() {
if (keyPressed) {
switch(key) {
case ‘a’:
x–;
break;
case ‘d’:
x++;
break;
}
}
}
//show the truck
void show() {
//wheels
//back
ellipse(x-12.5, y+25, 25, 25);
//front
ellipse(x+12.5, y+25, 25, 25);
}
}

First step: Learn how to post code on the forums! Edit your post, select your code, and hit the MAGIC CODE FORMATTING BUTTON, which looks like this: </>

1 Like

thank you for telling me that, but I just tried it and it doesn’t work. Am I doing something Wrong?

Please format your code :blush:

It consist on these two steps:

  1. In your code editor (PDE, VS code, Eclipse, etc) ensure you execute the beautifier function. This function automatically indents your code. Auto-indenting makes your code easier to read and helps catching bugs due to mismatch parenthesis, for instance. In the PDE, you use the key combination: ctrl+t
  2. You copy and paste your code in the forum. Then you select the code and you hit the formatting button aka. the button with this symbol: </>

That’s it! Please notice you do not create a new post in case you need to format something you already posted. You can edit your post, copy the code to the PDE, indent the code properly there and then past it back here, format the code and >> save << the edits.

Extra info:

Formatting your code makes everybody’s life easier, your code looks much better plus it ensures your code integrity is not affected by the forum’s formatting (Do you know the forum processes markup code?) Please visit the sticky posts or the FAQ section/post to learn about this, other advantages and super powers you can get in this brand new forum.

Kf

That helps a lot :smile:. thanks!

That sounds like a great project :smiley:

So, if I were you, I would first consider a lot of OOP, that being Object Oriented Programming. I would learn about classes, and managing objects, and all that.

I would also see how the different objects in my game would relate to each other. In terms of a map, I am assuming yours will be 3D, so I would get to looking maybe at a library such as P3D or another one that manages 3D objects?

I would also think about how I would make my map. Honestly, I have not made many games that include maps, but I do know that to do that I have seen two dimensional arrays used. And it would be something like this (I do not know if this specific approach is what you would do for a 3D game, but this is what you would do for a 2D one) :

int[][] gameMap = { 
{ 1,0,1,2,3,1,1},
{ 1,3,1,2,3,1,1},
{ 0,0,0,0,1,2,1},
{ 0,1,2,1,2,3,2},
};

And like, a 0 would map out to be a grass part, and a 1 is like water, 0 is a tree, and so on and so forth. You can build a whole map that way, if you would like to. And obviously, you would have a function to handle that and appropriately display what you want on the screen when you want.

So I see in the code that you posted, that you drew your truck, and while you are at it, I would also think about checking for collisions with other objects and such.

As of now, that is what comes to mind at first. I would also draw out my planned finished result and all, just so I know what I’m working towards. If you have any more questions I would love to do my best to help answer that, and hopefully all goes well with that project :joy:

EnhancedLoop7

1 Like

Hey,
I don’t know how you formatted you code but it should look like this:

class Truck { 
  //positioning 
  int x, y; 

  //wether the hopper is up 
  boolean hopperUp; 

  //move the truck 
  void move() { 
    if (keyPressed) { 
      switch(key) { 
      case 'a': 
        x--; 
        break; 
      case 'd': 
        x++; 
        break;
      }
    }
  } 
  //show the truck 
  void show() { 
    //wheels 
    //back 
    ellipse(x-12.5, y+25, 25, 25); 
    //front 
    ellipse(x+12.5, y+25, 25, 25);
  }
}

There are not so much we can do to help you right now but my advice you be divide to conquer! Start small and keep building on top of that. When you try to approach a new complicated part, code a sketch aside to get the concept done and then integrate it to your code.

Looking forward to see a first version :slight_smile:

1 Like

How do I make that function to read the Array? I’ve tried for about 15 days without luck and haven’t found any way to. May I have a coded example on how to do that?

You mean to read a two dimensional array? Can you please post what you’ve tried?

EnhancedLoop7