Hello all. I am new to programming in general but I have been going through craits game tutorials (which are fantastic). I was using his emulator in order to verify my work and it was working amazingly. Although today I started part 7 and I went to build the code and I keep getting this error "“Project does not contain an ino file”. I cannot figure out what is happening. Any help or suggestions would be great.
Thanks!
Hi Kristen,
Could you share your source code please? It might help troubleshoot your issue.
It is not my own code since I was following the how to tutorial. But I tried complete code like below and I get the same error.
//Jonathan Holmes (crait)
//December 7th, 2016
//A simple Pong clone
#include <Arduboy2.h>
Arduboy2 arduboy;
//Variables declared here
int gamestate = 0;
int ballx = 62;
int bally = 0;
int ballsize = 4;
int ballright = 1;
int balldown = 1;
int paddlewidth = 4;
int paddleheight = 9;
int playerx = 0;
int playery = 0;
int computery = 0;
int computerx = 127 - paddlewidth;
void setup() {
arduboy.begin();
//Seed the random number generator
arduboy.initRandomSeed();
//Set the game to 60 frames per second
arduboy.setFrameRate(60);
arduboy.clear();
}
void loop() {
//Prevent the Arduboy from running too fast
if(!arduboy.nextFrame()) {
return;
}
arduboy.clear();
arduboy.pollButtons();
//Game code here
switch( gamestate ) {
case 0:
//Title screen
arduboy.setCursor(0, 0);
arduboy.print("Title Screen");
//Change the gamestate
if (arduboy.justPressed(A_BUTTON)) {
gamestate = 1;
}
break;
case 1:
//Gameplay screen
arduboy.setCursor(0, 0);
arduboy.print("Gameplay");
//Draw the ball
arduboy.fillRect(ballx, bally, ballsize, ballsize, WHITE);
//Move the ball right
if(ballright == 1) {
ballx = ballx + 1;
}
//Move the ball left
if(ballright == -1) {
ballx = ballx - 1;
}
//Reflect the ball off of the left side of the screen
if(ballx == 0) {
ballright = 1;
}
//Reflect the ball off of the right side of the screen
if(ballx + ballsize == 127) {
ballright = -1;
}
//Move the ball down
if(balldown == 1) {
bally = bally + 1;
}
//Move the ball up
if(balldown == -1) {
bally = bally - 1;
}
//Reflect the ball off of the top of the screen
if(bally == 0) {
balldown = 1;
}
//Reflect the ball off of the bottom of the screen
if(bally + ballsize == 63) {
balldown = -1;
}
//Draw the player's paddle
arduboy.fillRect(playerx, playery, paddlewidth, paddleheight, WHITE);
//If the player presses Up and the paddle is not touching the top of the screen, move the paddle up
if(arduboy.pressed(UP_BUTTON) && playery > 0) {
playery = playery - 1;
}
//If the player presses down and the paddle is not touching the bottom of the screen, move the paddle down
if(arduboy.pressed(DOWN_BUTTON) && playery + paddleheight < 63) {
playery = playery + 1;
}
//Draw the computer's paddle
arduboy.fillRect(computerx, computery, paddlewidth, paddleheight, WHITE);
//If the ball is higher than the computer's paddle, move the computer's paddle up
if (ballx > 115 || random(0, 20) == 1) {
if (bally < computery) {
computery = computery - 1;
}
//If the bottom of the ball is lower than the bottom of the computer's paddle, move the comptuer's paddle down
if (bally + ballsize > computery + paddleheight) {
computery = computery + 1;
}
}
//If the ball makes contact with the player's paddle, bounce it back to the right
if (ballx == playerx + paddlewidth && playery < bally + ballsize && playery + paddleheight > bally) {
ballright = 1;
}
//If the ball makes contact with the computer's paddle, bounce it back to the left
if (ballx + ballsize == computerx && computery < bally + ballsize && computery + paddleheight > bally) {
ballright = -1;
}
//Change the gamestate
if (arduboy.justPressed(A_BUTTON)) {
gamestate = 2;
}
break;
case 2:
//Win screen
arduboy.setCursor(0, 0);
arduboy.print("Win Screen");
//Change the gamestate
if (arduboy.justPressed(A_BUTTON)) {
gamestate = 3;
}
break;
case 3:
//Game over screen
arduboy.setCursor(0, 0);
arduboy.print("Game Over Screen");
//Change the gamestate
if (arduboy.justPressed(A_BUTTON)) {
gamestate = 0;
}
break;
}
arduboy.display();
}
sorry correction it was this code.
//Jonathan Holmes (crait)
//December 7th, 2016
//A simple Pong clone
#include <Arduboy2.h>
Arduboy2 arduboy;
//Variables declared here
int gamestate = 0;
int ballx = 62;
int bally = 0;
int ballsize = 4;
int ballright = 1;
int balldown = 1;
int paddlewidth = 4;
int paddleheight = 9;
int playerx = 0;
int playery = 0;
int computery = 0;
int computerx = 127 - paddlewidth;
int playerscore = 0;
int computerscore = 0;
void resetGame() {
ballx = 63;
playerscore = 0;
computerscore = 0;
}
void setup() {
arduboy.begin();
//Seed the random number generator
arduboy.initRandomSeed();
//Set the game to 60 frames per second
arduboy.setFrameRate(60);
arduboy.clear();
}
void loop() {
//Prevent the Arduboy from running too fast
if(!arduboy.nextFrame()) {
return;
}
arduboy.clear();
arduboy.pollButtons();
//Game code here
switch( gamestate ) {
case 0:
//Title screen
arduboy.setCursor(0, 0);
arduboy.print("Title Screen");
//Change the gamestate
if (arduboy.justPressed(A_BUTTON)) {
gamestate = 1;
}
break;
case 1:
//Gameplay screen
//Display the player's score
arduboy.setCursor(20, 0);
arduboy.print(playerscore);
//Display the computer's score
arduboy.setCursor(101, 0);
arduboy.print(computerscore);
//Draw the ball
arduboy.fillRect(ballx, bally, ballsize, ballsize, WHITE);
//Move the ball right
if(ballright == 1) {
ballx = ballx + 1;
}
//Move the ball left
if(ballright == -1) {
ballx = ballx - 1;
}
//Move the ball down
if(balldown == 1) {
bally = bally + 1;
}
//Move the ball up
if(balldown == -1) {
bally = bally - 1;
}
//Reflect the ball off of the top of the screen
if(bally == 0) {
balldown = 1;
}
//Reflect the ball off of the bottom of the screen
if(bally + ballsize == 63) {
balldown = -1;
}
//Draw the player's paddle
arduboy.fillRect(playerx, playery, paddlewidth, paddleheight, WHITE);
//If the player presses Up and the paddle is not touching the top of the screen, move the paddle up
if(arduboy.pressed(UP_BUTTON) && playery > 0) {
playery = playery - 1;
}
//If the player presses down and the paddle is not touching the bottom of the screen, move the paddle down
if(arduboy.pressed(DOWN_BUTTON) && playery + paddleheight < 63) {
playery = playery + 1;
}
//Draw the computer's paddle
arduboy.fillRect(computerx, computery, paddlewidth, paddleheight, WHITE);
//If the ball is higher than the computer's paddle, move the computer's paddle up
if (ballx > 115 || random(0, 20) == 1) {
if (bally < computery) {
computery = computery - 1;
}
//If the bottom of the ball is lower than the bottom of the computer's paddle, move the comptuer's paddle down
if (bally + ballsize > computery + paddleheight) {
computery = computery + 1;
}
}
//If the ball moves off of the screen to the left...
if(ballx < -10) {
//Move the ball back to the middle of the screen
ballx = 63;
//Give the computer a point
computerscore = computerscore + 1;
}
//If the ball moves off of the screen to the right....
if(ballx > 130) {
//Move the ball back to the middle of the screen
ballx = 63;
//Give the player a point
playerscore = playerscore + 1;
}
//Check if the player wins
if(playerscore == 5) {
gamestate = 2;
}
//Check if the computer wins
if(computerscore == 5) {
gamestate = 3;
}
//If the ball makes contact with the player's paddle, bounce it back to the right
if (ballx == playerx + paddlewidth && playery < bally + ballsize && playery + paddleheight > bally) {
ballright = 1;
}
//If the ball makes contact with the computer's paddle, bounce it back to the left
if (ballx + ballsize == computerx && computery < bally + ballsize && computery + paddleheight > bally) {
ballright = -1;
}
//Change the gamestate
if (arduboy.justPressed(A_BUTTON)) {
gamestate = 2;
}
break;
case 2:
//Win screen
arduboy.setCursor(0, 0);
arduboy.print("Win Screen");
//Change the gamestate
if (arduboy.justPressed(A_BUTTON)) {
resetGame();
gamestate = 0;
}
break;
case 3:
//Game over screen
arduboy.setCursor(0, 0);
arduboy.print("Game Over Screen");
//Change the gamestate
if (arduboy.justPressed(A_BUTTON)) {
resetGame();
gamestate = 0;
}
break;
}
arduboy.display();
}
Sorry I don’t mean to ask the obvious, but just trying to rule out things. The file that contains this code is an .ino file, right? This is what a basic folder structure looks like including the run file, which is the .ino file.
Another thing I might mention is making sure the folder that holds these files should be the same name (case sensitive) as the .ino file name.
Unfortunately that is not obvious to me so no worries. I am using this https://felipemanga.github.io/ProjectABE/?url=new and previously I only had to type into it or copy and paste then build to get anything to run or work (test code). I have not yet had to deal with .ino files. Sorry to be so lost. Typically when using the emulator I just had to delete the old source code in the emulator and add my new code then build to run it. Now it gives that error.
So next to the “File:” dropdown does it have any .ino files you can select?
Only disassembly.s and when I click it then build I get the same error. I have even reloaded the page, closed it and gone back in yet it still has that issue.
Ah, okay so if you click the + at the far left of the screen you can create a new file. When you create one make sure to add .ino at the end of the name.
Wanna try that out?
That did it! Thank you so much. I really appreciate the help. Have a great rest of your day and take care.
Awesome! Happy we could solve this together. Happy coding!
I think you add [Solved] in your title so people know you are good.