Friday, August 3, 2018

c++ - Simulating Game Apples - Can't get it to work



I'm trying to create a game with newtonian physics.


Before you read the rest of this, this is my main question I'm trying to find an answer to:



  • I keep getting an error that pops up in a window after I try and run my code. What library or dll am I missing?



I've got an apple, an orange, and a pencil. I've read most of the documentation with the bullet physics engine, but I just can't seem to get the apple to behave like a piece of paper (2d-ish). Box2d physics engines and such aren't what I want. I don't like boxes in real life, let alone in cyberworlds.


I want the apple to float down to the ground, kind of swinging back and forth like a piece of paper would. This site gave some useful info that I integrated into my code: htp://www.3dbuzz.com/vbforum/showthread.php?50854-Please-HELP!!-Simulating-paper-floating-to-ground


I have this idea for a game where you make objects behave like other types of objects, but my simulations of the game just aren't working.


I've gone through too many types of apples to count, and none of them even come close. I've tried searching for other people who have tried similar things, (using googles like http://lmgtfy.com/?q=simluating+game+apples+in+real+life), but no apples are ever returned!


Thus, I think I'm going into new territory here (don't worry, I'll opened source my techniques), and that's why things just aren't working for me.


I've tried programming different kinds of apples, but maybe I need a cyber apple? I don't know where to get one of those, maybe at a place like this: http://cyberapples.com/ That site is down for now though - it's only ever talking about some cgi rubbish bin or something. Any tips on this as well?


This is the part of my code that deals with the apple simulating a game stuff:


///... /* setup other objects in the room and other stuff */ ...

// see http://www.orangepippin.com/apples/arlet-swiss-gourmet

// for more arlet apple details
paper_2d_behaving_apple = new ArletApple[);

/ setup the arlet apple's general characteristics
paper_2d_behaving_apple.species = SPECIES.MALUS_DOMESTICA;
paper_2d_behaving_apple.parentage = PARENTAGE.GOLDEN_DELICIOUS_X_IDARED:
paper_2d_behaving_apple.introduced = make_year(1958);
paper_2d_behaving_apple.fruitColor = COLORS.red;
paper_2d_behaving_apple.fleshCOlor = APPLE_FLESH_COLORS::CREAM;
paper_2d_behaving_apple.fruitSize = GENERIC_FRUIT_SIZES.MEDIUM;

paper_2d_behaving_apple.GoodFor.add("eating fresh");
paper_2d_behaving_apple.GoodFor.add("cooking");
paper_2d_behaving_apple.GoodFor.add("use / keeping: 3 months or more");
paper_2d_behaving_apple.GoodFor.add("ripening PERIOD: 3 months or more");
paper_2d_behaving_apple.diseaseResistances = [DISEASE_RES::SCAB, DISEASE_RES::MILDEW];
///... (I cut some of this out for brevity's sake) ...

///* setup this specific apple's characteristics
paper_2d_behaving_apple.base_color = 0xff2000;
paper_2d_behaving_apple.bumpMap = BUMP_MAP_APPLE;

paper_2d_behaving_apple.texture = TEXTURE_REALISTIC_APPLE;
paper_2d_behaving_apple.feel_texture = SMOOTH;
paper_2d_behaving_apple.has_small_orangey_stripes = TRUE;
paper_2d_behaving_apple.DoesntHaveStem = FALSE;
paper_2d_behaving_apple.juicy = true; // needs a lowercase true for some reason
paper_2d_behaving_apple.has_bugs = false; // heck no it doesn't, I only buy good apples
///... (again I cut some stuff out so this post would'n't be too long) ...

// from http://www.3dbuzz.com/vbforum/showthread.php?50854-Please-HELP!!-Simulating-paper-floating-to-ground
// "i think reactor can do this, i would try cloth witha high air resistance and a very high stifness"

paper_2d_behaving_apple.addReactor(REactor());
// got this technique from http://www.gimptutorials.eu/html/clothify_filter_gimp_gnu.html
import gimp ; GIMP::Clothify(paper_2d_behaving_apple); pass
// / 7 should be high enough - it's a big number
paper_2d_behaving_apple.reactor.stiffness = 7.0f;
paper_2d_behaving_apple.reactor.airResistance = 5.0f; // high, but not "very high"

// setup the world the apple exists in
paper_2d_behaving_apple.owner = new BobFlanderson();
paper_2d_behaving_apple.owner.appearance = APPEARANCE_AWESOME;

paper_2d_behaving_apple.owner.clothes.size = CLOTHES_SIZE_MEDIUM;
paper_2d_behaving_apple.owner.owns_house = false;
paper_2d_behaving_apple.owner.apartment.sucks = true;
paper_2d_behaving_apple.owner.has_wife = false;
paper_2d_behaving_apple.viewSpace = LIVING_ROOM;
paper_2d_behaving_apple.RESTINGon = Kitchen.GetSurfaces()->COUNTER_BY_STOVE;
////... (also cut some more out here too) ...

// transform the paper behaving apple into something viewable
view_matrix = new ViewMatrix();

view_matrix.DoTransformation(paper_2d_behaving_apple);
view_matrix.makeViewable();
World->ApplyViewMatrix(view_matrix);

paper_2d_behaving_apple.RenderToNeakedEye();

// THIS IS WHERE I'm HAVING THE TROUBLE
actual_existing_apple_on_myCounter = new ExistingApple(paper_2d_behaving_apple);
actual_existing_apple_on_myCounter.bindInRealLive();


// THIS NEVER WORKS! I DON"T KNOW HOW YOU GUYS DO THIS STUFF!
actual_existing_apple_on_myCounter.Translate(LANGUAGES::ENGLISH);
// saw the IW_FIXED on some jam making site
// (http://www.madewithmarmalade.com/devnet/documentation#/api/api/group__IwGeomCore.html)
// - that's the closest I've come to seeing anything close to what
// I'm trying to do
actual_existing_apple_on_myCounter.TranslateTo(0, 0, IW_FIXED(10.0f));
apple_now_inAir = actual_existing_apple_on_myCounter;

// I know this is C++ code, but some ruby sites were saying that it's best

// to put an exclamation point after a function that modifies a physical
// object - no luck yet for me
apple_now_inAir.Drop!();

As you can see, I've got the basic concepts down, and I'm being very descriptive with my variable names and the object attributes. I setup the world very succinctly and clearly, although I've simplified the world in the game as compared to actual kitchen.


I think the problem is binding the paper_2d_behaving_apple to the actual_existing_apple_on_myCounter apple, and then transferring that to the one in the air (apple_now_inAir);


Whatever the case is, and no matter how well I format everything, nothing seems to happen. Below is an image of how I run the program:


enter image description here


Has anybody run into this before? Thanks in advance. I'm just starting out with programming games, having recently switched careers, so don't feel bad.


Thanks, Bob





No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...