ArduSniper - Sniper game for Arduboy


Why not everyone? :open_mouth: and you post the game here


Okay fine :stuck_out_tongue:

I’ll make an official post when it’s final I guess

Try to beat my high score (770)

Hi JoeRagu, these are my first impressions to your game : I had to delete the line 14 “arduboy.safeMode();” to make the game work. The music is great ! Why not a FPS ? I don’t really like to see the guy standing on this platform and this line to aim at the targets. It is strange to read “YOU WIN” when we lost our lives and the game is over. And nothing hurts us so why my health decreases ? No ennemis are shooting on us… Do you like “Duck Hunt” on Nes or “Silent Scope” on Dreamcast ? I like those games. Do you want to make a game about sniper training on abstrat targets or is it possible to shoot on more moving and fun targets ? Is there a story in this game ? Why do I shoot on targets ? Do you have other ideas for the game title ? I don’t think it’s a good idea if every game on Arduboy is caled “Ardu-something”. There is maybe some bugs on the score at the end of the game because I hade a score with a minus once. Go on ! This game is already good, it could be even better. Thank you for creating this game for the Arduboy community !



Honestly this is my first experiment using collision detection so I wanted to keep it simple[quote=“JuiceLizard, post:4, topic:3622”]

And nothing hurts us so why my health decreases ?

When you miss a target you lose some health :stuck_out_tongue:[quote=“JuiceLizard, post:4, topic:3622”]
There is maybe some bugs on the score at the end of the game because I hade a score with a minus once.

Fixed that. Had the score calculate on every frame but now made it execute only once. Also I didn’t think anyone would get past level 5 was it hard?

I’ll come up with something more original

Thanks for the review!

Fixed. In the final screen I had win = true; right at the top haha. Used it for debug.

1 Like

You need to update the Arduboy2 library to the latest V4.0.0

Sketch > Include Libraries > Manage Libraries...
Enter Arduboy2 in the Filter your search… field.

Works perfectly. I have some suggestions:

  • It might be more fun to “point” to the target and when you fire the bullet “extends that line” until it crosses the objective, so the targets become tiny after each level and you start getting a shorter sight
  • Sounds effects are great
  • At the end only the happy face should appear, not a new challenge
  • I am missing some extra challenge, maybe a moving target?

In the final version i’ll do something like that. I have to research how that collision works. I’m thinking has as to do with y=mx+b and slopes

Hmm… where would the player go from there though? If the user wanted to play again they would have to power cycle the device? Press A to go to main menu?

I like that. On the topic of switching sprites for the target, is there a way to store the sprite name in a variable and draw it that way?

Example 1 (Preferred):

char currentTarget[]= "target1"; //Variable will be set each level based on difficulty level


Example 2: or would you have to have to do it in a switch statement (not prefered)

#define SPRITE_A 1
#define SPRITE_B 2

int currentSprite = SPRITE_A; //Variable will be set each level based on difficulty level

switch (currentSprite)
case SPRITE_A:
case SPRITE_B:

Oh, I mean, after you finish a round then I see a smile face near the shooter and a target in the screen at the same time. It is only a visual thing

Oh I understand what you mean. The main game.h is a bit of a mess and that will be sorted after i divide everything into functions

I think you can’t do exactly what you expect from the example 1, but you can try to find an alternative with pointers.

If you use the Sprites class, related sprites can be stored in the same array and then selected via an index. It’s intended to allow animating sprites by changing the index each time the sprite is re-drawn but it could also be used to change the sprite less frequently, as you would like to do (as long as the overall dimensions of the sprite remain the same).

Yes I have used the sprites library in the past but like you said the sprites will be different sizes…

In the examples you gave, they were all 16 x 16.

For variable size sprites, you could use an array of parameters. If the sprite drawing function you use doesn’t include the dimensions in the sprite itself, you could use an array of structures. Otherwise, just an array of pointers would do.

I hope I got this right but it’s untested:

EDIT: When I first posted the following code, I didn’t account for the name pointer in the mySprites array being in program memory. I’ve corrected this (but it’s still untested).

enum {

struct sprite {
  const unsigned char* name;
  byte width;
  byte height;

const unsigned char spriteA[] PROGMEM = {
  /* sprite data here */

const unsigned char spriteB[] PROGMEM = {
  /* sprite data here */

const sprite mySprites[] PROGMEM = {
  { spriteA, 16, 16 },
  { spriteB, 8, 8 }

byte currentSprite;

// To select a sprite and draw it:
  currentSprite = SPRITE_A; // or SPRITE_B
  arduboy.drawSlowXYBitmap(3, 20, 
                           (const unsigned char *) pgm_read_ptr(&mySprites[currentSprite].name),
1 Like

I think what @MLXXXp says should work. I did something similar in a previous game, but implemented in a crappier way:

The playerSpecs enum contained the graphics, mask and size data for the collisions. So I just had to use that in the game loop:

playerSpecs player = playerTypes[currentLevel];
arduboy.drawBitmap(floor(playerx), floor(playery), player.bitmap, player.width, player.height);

I have just implemented this. The line can only be moved up and down and collision is detected based on ax + by = c.

You no longer have to put the line directly touching the target to collide.

Now I just have to animate the bullet. Try it out.

1 Like

Bullets fully work now. :gun: :smile:

Now you just move the crosshair up and down and we don’t have to deal with that ugly laser

Nice! The led effects are super cool!

For some reason gets really slow after the first stage. Also some feedback:
-Pistol does not move
-Maybe the thing the player is moving could move in an arc? and have some trails: … from the pistol in the first levels to help aiming
-Shields is written Sheilds
-Sometimes the target overlaps with the HUD (shields)

@JoeRagu You can determine if the game is able to keep up with rendering at the set frame rate (currently 30 FPS) by changing the nextFrame() call to nextFrameDEV(). Then, any frame that takes longer than the time available to render will light the yellow TX LED above the reset button.

Once you’ve finished the game and are happy with the speed, you can change it back to nextFrame() for general release.

One thing you should do is only enable screen mirroring over Serial when you want to use it. You can do this by conditionally compiling the Serial functions:

At the top of the sketch put

// Uncomment the following line to enable screen mirroring

Then use #ifdef to control compilation of the mirroring code

  //Serial Mirror
  Serial.write(arduboy.getBuffer(), 128 * 64 / 8);
1 Like

Thanks! I will use nextFrameDEV() when developing from now on.

Yes I will also use the #idfef way do toggle serial and i’m going to comment the definition out

1 Like