Set pixel in the world, not on the screen.
Moderators: Chuckt, Garth, bitfogav
- ZephaniahNoah
- semi-newbie
- Posts: 24
- Joined: Wed Dec 31, 2014 7:17 am
- Location: Milky Way, Earth [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Set pixel in the world, not on the screen.
Haha! I took some parts off my Arduino for another project too.
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Set pixel in the world, not on the screen.
I do apologise for not getting around to this yet. I've had quite a busy few days!
But as soon as I can get some time i'll try it out
But as soon as I can get some time i'll try it out
- ZephaniahNoah
- semi-newbie
- Posts: 24
- Joined: Wed Dec 31, 2014 7:17 am
- Location: Milky Way, Earth [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Set pixel in the world, not on the screen.
Okay, I have finally managed to getting around to testing your game. It's a big world!
I should have asked this question before, but are you saying that when you go in the hut and press down on the rope that it does work as long as the code is not over 17,000 bytes? Or does it just not work all of the time no matter what the code size?
Have you experimented with comparing your players x/y co-ordinates with the data coming straight from the constant arrays (where the level data is stored) instead of using the getpixel function?
I should have asked this question before, but are you saying that when you go in the hut and press down on the rope that it does work as long as the code is not over 17,000 bytes? Or does it just not work all of the time no matter what the code size?
Have you experimented with comparing your players x/y co-ordinates with the data coming straight from the constant arrays (where the level data is stored) instead of using the getpixel function?
- ZephaniahNoah
- semi-newbie
- Posts: 24
- Joined: Wed Dec 31, 2014 7:17 am
- Location: Milky Way, Earth [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Set pixel in the world, not on the screen.
Yes, the code works if it's below about 17,000 bytes. As soon as I deleted some other code so that the total project consisted of 16,726 bytes, the getPixel function started working again. But when it was over 17,000 bytes, the getPixel function completely stopped working. Everything works except getPixel when the code is above 17,000 bytes approximately. Everything works, including getPixel, when the code is below 17,000 bytes.
EDIT: Do you mean test ScreenYOffset & ScreenXOffset instead of using getPixel to test? At the very beginning of the game it tests the screen offset variables to see if you're on the button when you press B to open the first door. So that works but getPixel doesn't unless I delete some code to be under 17,000 bytes.
I don't quite understand. What is the data from the constant arrays?Have you experimented with comparing your players x/y co-ordinates with the data coming straight from the constant arrays (where the level data is stored) instead of using the getpixel function?
EDIT: Do you mean test ScreenYOffset & ScreenXOffset instead of using getPixel to test? At the very beginning of the game it tests the screen offset variables to see if you're on the button when you press B to open the first door. So that works but getPixel doesn't unless I delete some code to be under 17,000 bytes.
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Set pixel in the world, not on the screen.
I've looked into a few things with the memory problem but I just can't find anything that would be causing problems only when it goes above 17,000 bytes - since the Arduino Uno can go up to around 30,000 bytes.
With the constant arrays I'm talking about the arrays that hold your level data E.G.
Here's the code for the GetPixel function:
Instead of using GetPixel, I'm wondering if you could check the mydatabarrier array to see if there are logic 1's there (or not) to then determine what you want to do in the game.
In response to your edit, You are exactly right - you would use your offset x and y co-ordinates to figure out which pixels to check in the constant array(s) in this case, really just your barrier array.
Does that make any sense?
With the constant arrays I'm talking about the arrays that hold your level data E.G.
Code: Select all
long MyDataRed[700]PROGMEM={0b00100001000000001000011111000000,
Code: Select all
byte DigiPixel::getPixel(byte pixelX, byte pixelY){
bitWrite(tempByte, 0, bitRead(bufferRed[pixelX], pixelY));
bitWrite(tempByte, 1, bitRead(bufferGreen[pixelX], pixelY));
bitWrite(tempByte, 2, bitRead(bufferBlue[pixelX], pixelY));
bitWrite(tempByte, 3, bitRead(bufferBarriers[pixelX], pixelY));
return tempByte;
}
In response to your edit, You are exactly right - you would use your offset x and y co-ordinates to figure out which pixels to check in the constant array(s) in this case, really just your barrier array.
Does that make any sense?
Re: Set pixel in the world, not on the screen.
Can you post the code that doesn't work? Because I have tried your code you posted and added more to it and it runs with no problems, even over 17000 memory bytes.
If you don't know what Voltage your country is using, you shouldn't be doing electronics
- ZephaniahNoah
- semi-newbie
- Posts: 24
- Joined: Wed Dec 31, 2014 7:17 am
- Location: Milky Way, Earth [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Set pixel in the world, not on the screen.
Yea Brad, that makes sense. It's just convenient being able to just type digiPixel.getPixel(X,Y) and it's sad I won't be able to use it in this way. At least it I can use the screen offset.
That is the code that doesn't work. Did you press B or down on the rope? Or jump in the lava? Those two things use getPixel. The button uses ScreenOffset which does work above 17,000 bytes.bitfogav wrote:Can you post the code that doesn't work? Because I have tried your code you posted and added more to it and it runs with no problems, even over 17000 memory bytes.
- ZephaniahNoah
- semi-newbie
- Posts: 24
- Joined: Wed Dec 31, 2014 7:17 am
- Location: Milky Way, Earth [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Set pixel in the world, not on the screen.
Aha! I was wrong! When I deleted some code I came to the assumption that it was the amount of code that caused the problem. But it was the code I deleted that was the problem. Here's the code:
When I delete this code, plus button and door in void loop, getPixel works again. Any idea why this would cause getPixel to fail? I'm curios to see why it worked for bitfogav.
EDIT: Also I mentioned earlier when I added the download that I use Arduino 1.0.6. But the reason for that is because I had troubles getting the DigiPixel libraries working with newer versions. And I wonder if bitfogav is using a newer version of Arduino. Or maybe uses a Digispark or other Arduino campatable microcontroller. Anyways, I really want to get to working on this again. I'll be experimenting with my code and different versions of Arduino.
Code: Select all
//BUTTON! \/
void button(){
if (-ScreenYOffset+ButtonY > -1){
digiPixel.setPixel(-ScreenXOffset+ButtonX,-ScreenYOffset+ButtonY,ButtonColor);
}
if (ScreenXOffset < 24){
if (digiPixel.buttonBPressed){
if (ScreenYOffset == 23 & ScreenXOffset == 2){
ButtonColor = 10;
ButtonPress = true;
}
}
}
}
//DOOR! \/
void door(){
if (ButtonPress == false){
if (-ScreenYOffset+DoorY > -1){
digiPixel.setPixel(-ScreenXOffset+DoorX,-ScreenYOffset+DoorY,13);
}
if (-ScreenYOffset+DoorY > -1){
digiPixel.setPixel(-ScreenXOffset+DoorX,-ScreenYOffset+DoorY-1,13);
}
}
}
EDIT: Also I mentioned earlier when I added the download that I use Arduino 1.0.6. But the reason for that is because I had troubles getting the DigiPixel libraries working with newer versions. And I wonder if bitfogav is using a newer version of Arduino. Or maybe uses a Digispark or other Arduino campatable microcontroller. Anyways, I really want to get to working on this again. I'll be experimenting with my code and different versions of Arduino.
Re: Set pixel in the world, not on the screen.
When I come to the red hut I then push down to go down the rope (with no issues), button B doesn't seem to do anything when I'm at the rope?. I then come to the lava and fall into the lava and the game resets. is this not correct??.ZephaniahNoah wrote:That is the code that doesn't work. Did you press B or down on the rope? Or jump in the lava? Those two things use getPixel. The button uses ScreenOffset which does work above 17,000 bytes.bitfogav wrote:Can you post the code that doesn't work? Because I have tried your code you posted and added more to it and it runs with no problems, even over 17000 memory bytes.
I saw you was using the old classic version 1.0.6 arduino, I am testing you're code using the latest Arduino IDE version 1.6.5, I have had no problems importing the digipixel library into this version.ZephaniahNoah wrote:Aha! I was wrong! When I deleted some code I came to the assumption that it was the amount of code that caused the problem. But it was the code I deleted that was the problem. Here's the code:
EDIT: Also I mentioned earlier when I added the download that I use Arduino 1.0.6. But the reason for that is because I had troubles getting the DigiPixel libraries working with newer versions. And I wonder if bitfogav is using a newer version of Arduino. Or maybe uses a Digispark or other Arduino campatable microcontroller. Anyways, I really want to get to working on this again. I'll be experimenting with my code and different versions of Arduino.
There was only one change I had to make to you're code to work with version 1.6.5 and that was to list the programme memory arrays to "const".
From:
Code: Select all
long MyDataRed[700]PROGMEM={0b00100001000000001000........etc
Code: Select all
const long MyDataRed[700]PROGMEM={0b00100001000000001000.......etc
If you don't know what Voltage your country is using, you shouldn't be doing electronics
- ZephaniahNoah
- semi-newbie
- Posts: 24
- Joined: Wed Dec 31, 2014 7:17 am
- Location: Milky Way, Earth [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Set pixel in the world, not on the screen.
No, that is correct. I guess I'll try the new Arduino. I hope this works!bitfogav wrote:When I come to the red hut I then push down to go down the rope (with no issues), button B doesn't seem to do anything when I'm at the rope?. I then come to the lava and fall into the lava and the game resets. is this not correct??.
Re: Set pixel in the world, not on the screen.
If you need help installing the digipixel library after updating to the latest Arduino IDE then you can find more info here
https://www.arduino.cc/en/Guide/Libraries#toc2
I normally just put the digipixel folder (unzipped) into the Arduino library folder and restart the Arduino IDE if you have the IDE already running?.
if your using a windows PC then usually you're find the Arduino library folder in "My Documents" under Arduino>libraries.
https://www.arduino.cc/en/Guide/Libraries#toc2
I normally just put the digipixel folder (unzipped) into the Arduino library folder and restart the Arduino IDE if you have the IDE already running?.
if your using a windows PC then usually you're find the Arduino library folder in "My Documents" under Arduino>libraries.
If you don't know what Voltage your country is using, you shouldn't be doing electronics
- ZephaniahNoah
- semi-newbie
- Posts: 24
- Joined: Wed Dec 31, 2014 7:17 am
- Location: Milky Way, Earth [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Set pixel in the world, not on the screen.
Yay! Thanks. I installed it successfully and getPixel works now!
Re: Set pixel in the world, not on the screen.
That's great!!.. keep us updated on how you get on with you're game, I'll look forward to trying it out
If you don't know what Voltage your country is using, you shouldn't be doing electronics
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Set pixel in the world, not on the screen.
Sorry for being late to reply here again and great job there bitfogav!
I apologise for being away but I've been quite busy getting things all organised for the DigiRule Kickstarter campaign.
Great to hear it is working and as bitfogav said, let us know how it is going for you
I apologise for being away but I've been quite busy getting things all organised for the DigiRule Kickstarter campaign.
Great to hear it is working and as bitfogav said, let us know how it is going for you
Who is online
Users browsing this forum: No registered users and 2 guests