[Game]Racers [wip]

I do like the 98 version better, to me it reads a little easier. But does it take up more memory since its 2 lines instead of 1 line ?

You can do things 98 style if you want, other version isn’t mandatory.
Bear in mind though that you don’t do the initialisation immediately underneath the declaration as Jonne’s example might suggest, the initialisation happens elsewhere (usually in the constructor).
Personally I prefer C++11 style because it’s easy to see what the default value of a member variable is without having to look elsewhere (i.e. at the constructor).

As far as C++98 vs C++11 goes there are much bigger changes than that.
(Though I suspect mbed online is probably C++03, I’d be surprised if it were C++98.)

Just noticed this : https://wiki.python.org/moin/TOOWTDI
If Python really is simpler, in the way you can only do it one way, i might wanna try that. ( @Hanski)

1 Like

Python is an easier language for beginners, but there’s a memory overhead involved in using it and programs written with it won’t be as fast as those written with C++.
(I don’t know how big the memory and speed difference is though.)

C++ is more flexible and (arguably) more powerful but that power and flexibility comes at the cost of complexity.
Conversely Python is a lot less complicated but that simplicity comes with restrictions in flexibility and (arguably) power.

you can just write more in a c style, you dont have to use everything c++ is giving you like templates and even classes

i mainly miss auto in C++98 :stuck_out_tongue:

True, though the only reason I can think for avoiding them is if you don’t understand them.

I’d miss nullptr, constexpr, enum class, auto, decltype, static_assert, template aliases, rvalue references… C++11 was a really big change.

there allot of things in c++ i dont understand, and i did a cource on it XD

@wuuff here´s an improved version, there was only some mistakes with FPS…
Also i added the scrolling background :slight_smile:

Racers A 1.1.bin (46,6 KB)

2 Likes

It’s a lot better. I like how everything moves faster, including your car. However, I still got trapped a few times, although it’s a lot rarer. It seems like the background isn’t scrolling for me though.

1 Like

What do you mean by that? Isn’t it working or looks it just crappy?

can you show the scrolling code?
i just came across a similar issue giving odd behaviour

He hey @Zuzu36 ! The first game I loaded to Pokitto on my new mac was Racers! We’re playing it now and we like it. Good job!

EDIT: it reminds me of driving on German Autobahn … equally stressful!

1 Like

It isn’t moving at all. It looks like it did in the other version.

Same here, just tested it on my pokitto, ground is not moving. Also because cars are not animated they don’t seem to be driving, as much as falling/sliding.

What size are your cars (pixels)? If I have some spare time on the weekend I can look into making some and look into adding some simple animation (even just moving the white pixel on tires would do wonders to give the illusion of driving).

1 Like

if he did what i suggested to minimise the sprite duplication, every part should be its own little sprite
so you could animate the wheels independent from the car body

Ohhhhh… I made a stupid mistake. I forgot to move the background, scrolling should work now:
Racer A 1.2.bin (46,6 KB)

Thanks :wink:[quote=“VonBednar, post:34, topic:627”]
If I have some spare time on the weekend I can look into making some and look into adding some simple animation (even just moving the white pixel on tires would do wonders to give the illusion of driving).
[/quote]

Thanks, but I want that the game is as easy as possible --> No animations :disappointed:

No, I just used the whole racer picture. (I know, its not best choice, but easier for my :confused:)

I must add that I´m really happy that you try helping me, but I just want to program these game to understand what´s going on in programming :slight_smile:. Maybe I need to use little sprite parts (@adekto) or animated textures (@VonBednar) in my next game. As soon as the game is ready, I will share the code and everybody can add what he want´s :wink:

3 Likes

you be surprised how easy it is the things we are talking about

theres ofcource classes but maybe stick to a simpler function model

void drawRacer(int x, int y, int color){
     game.display.drawBitmap(x,y,wheelSprite);
     game.display.drawBitmap(x+8,y,wheelSprite);
     game.display.drawBitmap(x,y+7,wheelSprite);
     game.display.drawBitmap(x+8,y+7,wheelSprite);

     game.display.rotatePalette(color);
     game.display.drawBitmap(x+3,y,bodySprite);
     game.display.rotatePalette(-color);
}

and wheel animation something as simple as this would do

// sprite
const uint8_t wheel[][6]={
  {2,4,
  0x01, 0x00, 0x00, 0x00},
  {2,4,
  0x00, 0x01, 0x00, 0x00},
  {2,4,
  0x00, 0x00, 0x01, 0x00},
  {2,4,
  0x00, 0x00, 0x00, 0x01},
};

//how do draw it
game.display.drawBitmap(x,y,wheel[frame]);
//how to loop the animation
frame ++;
frame = frame%4;
2 Likes

I see, it´s easy. But it will be complicaded because of my differend vehicel types: At the moment there tanks and a few cars are using colored wheels/spoilers.

Thanks for helping, i will see if i make use of it, probably not in this game but i have already ideas for more :video_game:

1 Like

sure thing, but adding those extra versions or modification is also trivial.

ether way i hope you look into it
also if you wanna know how the sprite file format works just tell me cuz i kinda made that by hand without using an image converter :stuck_out_tongue:

1 Like

I’m just getting a solid grey background on the newest version, with no road drawn at all. Can anybody else confirm it’s not just me?