Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 98 users online: 3 members, 71 guests and 24 bots. Members: legodude, Piguy-3.14. Bots: MSN/Bing (1), Magpie Crawler (4), Googlebot (19).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
|
| Author |
Message |
|
zeldaking
Power User

Joined: 31 Jul 2011 Posts: 470 Location: Utah
|
Posted: 22 Apr 2012 05:47:41 pm Post subject: |
|
|
| Well then they aren't Global variables. Make them before you start the int main() loop. Try that. Read a tutorial please, it will make life more enjoyable. |
|
| Back to top |
|
|
Ashbad

... I think redheaded girls are kind of cool

Joined: 01 Dec 2010 Posts: 2417 Location: Stomp Stomp Stomp, The Idiot Convention
|
Posted: 22 Apr 2012 05:51:18 pm Post subject: |
|
|
Could you show us where and how they're defined, and the errors they provide? _________________ -Ashbad |
|
| Back to top |
|
|
Spenceboy98

Super-Expert

Joined: 06 Jan 2012 Posts: 823 Location: In the TARDIS
|
Posted: 22 Apr 2012 05:59:33 pm Post subject: |
|
|
Code: struct Coord cur;
cur.x = 128;
int w = rand()%(340-45+1) + 45;
int b = rand()%(340-45+1) + 45;
int j = 0;
int s = 0;
while(1) {
int key = PRGM_GetKey();
if(key == KEY_PRGM_MENU) { GetKey(&key); }
moveCursor(&cur);
CopySprite(BulletBackground, 0, 0, 384, 216);
CopySpriteMasked(SpenBullet, cur.x, 159, 38, 43, COLOR_RED);
CopySpriteMasked(Banana, w, j, 75, 80, COLOR_RED);
CopySpriteMasked(LSDOMG, b, j, 34, 34, COLOR_RED);
if(w == cur.x && j == 159)
break;
if(b == cur.x && j == 159)
s++;
j+=8;
if(j > 216) {
int j = 0;
int w = rand()%(340-45+1) + 45;
int b = rand()%(340-45+1) + 45;}
if(keydown(KEY_PRGM_EXIT)
break;
Bdisp_PutDisp_DD();
Bdisp_AllCr_VRAM();
} }
if(keydown(KEY_PRGM_SHIFT) && y == 145) {
while(1) {
CopySprite(Instructions, 0, 0, 384, 216);
if(keydown(KEY_PRGM_EXIT))
break;
Bdisp_PutDisp_DD();
Bdisp_AllCr_VRAM();
}
return 0;
}
Bdisp_PutDisp_DD();
Bdisp_AllCr_VRAM();
}
return 0;
}
What it gives me:
Code: main.c:104:7: warning: unused variable 'b' [-Wunused-variable]
main.c:103:7: warning: unused variable 'w' [-Wunused-variable]
main.c:102:7: warning: unused variable 'j' [-Wunused-variable]
main.c:106:5: error: expected ')' before 'break'
main.c:109:3: error: expected expression before '}' token
make: *** [main.o] Error 1
By the way, I don't see anything about global variables in the tutorial. |
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
|
| Back to top |
|
|
Ashbad

... I think redheaded girls are kind of cool

Joined: 01 Dec 2010 Posts: 2417 Location: Stomp Stomp Stomp, The Idiot Convention
|
Posted: 22 Apr 2012 06:06:34 pm Post subject: |
|
|
Well, you're creating two sets of the b, w, and j variables inside the while loop, effectivly ignoring the higher-scoped ones. If you're just trying to reset those ones instead of making new ones, take the 'int' away from each time you try to feed them new values. _________________ -Ashbad |
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
Posted: 22 Apr 2012 06:12:13 pm Post subject: |
|
|
| Quote: | | By the way, I don't see anything about global variables in the tutorial. |
In that case, you should use Google to find out what global variables are. Not everything is going to be explained in a tutorial, and you might have to do a bit of searching to find what you're looking for. _________________ CALCnet Tournament-38%
deviantArt
 |
|
| Back to top |
|
|
Spenceboy98

Super-Expert

Joined: 06 Jan 2012 Posts: 823 Location: In the TARDIS
|
Posted: 22 Apr 2012 06:14:42 pm Post subject: |
|
|
| It works now, but the sprites that use the rand get generated every frame. So it looks like are getting jerked around. |
|
| Back to top |
|
|
Ashbad

... I think redheaded girls are kind of cool

Joined: 01 Dec 2010 Posts: 2417 Location: Stomp Stomp Stomp, The Idiot Convention
|
Posted: 22 Apr 2012 06:15:58 pm Post subject: |
|
|
What type of effect are you going for then, with their movements? _________________ -Ashbad |
|
| Back to top |
|
|
Spenceboy98

Super-Expert

Joined: 06 Jan 2012 Posts: 823 Location: In the TARDIS
|
Posted: 22 Apr 2012 06:17:12 pm Post subject: |
|
|
| I'm making an object scroll to the bottom of the screen and when the object hits the bottom, it generates a new one. |
|
| Back to top |
|
|
Ashbad

... I think redheaded girls are kind of cool

Joined: 01 Dec 2010 Posts: 2417 Location: Stomp Stomp Stomp, The Idiot Convention
|
Posted: 22 Apr 2012 06:18:35 pm Post subject: |
|
|
| Spenceboy98 wrote: | | I'm making an object scroll to the bottom of the screen and when the object hits the bottom, it generates a new one. |
Then each frame you should check to see if the enemy's y position is at or past a certain point, and if it is, then reset it with the rand function. _________________ -Ashbad |
|
| Back to top |
|
|
Spenceboy98

Super-Expert

Joined: 06 Jan 2012 Posts: 823 Location: In the TARDIS
|
Posted: 22 Apr 2012 06:20:29 pm Post subject: |
|
|
I did. It does it still. Here's code:
Code: int main() {
int y = 129;
while(1) {
int key = PRGM_GetKey();
if(key == KEY_PRGM_MENU) { GetKey(&key); }
CopySprite(BulletMenu, 0, 0, 384, 216);
CopySpriteMasked(BulletMenuSelector, 7, y, 18, 16, COLOR_RED);
if(keydown(KEY_PRGM_UP) && y>129)
y-=16;
if(keydown(KEY_PRGM_DOWN) && y<145)
y+=16;
if(keydown(KEY_PRGM_SHIFT) && y == 129) {
while(1) {
struct Coord cur;
cur.x = 128;
int w = rand()%(340-45+1) + 45;
int b = rand()%(340-45+1) + 45;
int j = 0;
int s = 0;
int key = PRGM_GetKey();
if(key == KEY_PRGM_MENU) { GetKey(&key); }
moveCursor(&cur);
CopySprite(BulletBackground, 0, 0, 384, 216);
CopySpriteMasked(SpenBullet, cur.x, 159, 38, 43, COLOR_RED);
CopySpriteMasked(Banana, w, j, 75, 80, COLOR_RED);
CopySpriteMasked(LSDOMG, b, j, 34, 34, COLOR_RED);
if(w == cur.x && j == 159)
break;
if(b == cur.x && j == 159)
s++;
j+=8;
if(j < 216) {
j = 0;
w = rand()%(340-45+1) + 45;
b = rand()%(340-45+1) + 45;}
if(keydown(KEY_PRGM_EXIT))
break;
Bdisp_PutDisp_DD();
Bdisp_AllCr_VRAM();
} }
if(keydown(KEY_PRGM_SHIFT) && y == 145) {
while(1) {
CopySprite(Instructions, 0, 0, 384, 216);
if(keydown(KEY_PRGM_EXIT))
break;
Bdisp_PutDisp_DD();
Bdisp_AllCr_VRAM();
}
return 0;
}
Bdisp_PutDisp_DD();
Bdisp_AllCr_VRAM();
}
return 0;
}
|
|
| Back to top |
|
|
Ashbad

... I think redheaded girls are kind of cool

Joined: 01 Dec 2010 Posts: 2417 Location: Stomp Stomp Stomp, The Idiot Convention
|
Posted: 22 Apr 2012 06:22:06 pm Post subject: |
|
|
I'm not sure if I'm allowed to help you with your contest entry to the point of writing some code for you, but I can make one suggestion so that I can make some points about why it might not be working: I can hardly read that code. Perhaps tab it in correctly, and use curly bracket blocks for if-statements when possible? _________________ -Ashbad |
|
| Back to top |
|
|
KermMartian

Site Admin

Joined: 14 Mar 2005 Posts: 55749 Location: Earth, Sol, Milky Way
|
Posted: 22 Apr 2012 06:26:10 pm Post subject: |
|
|
| Spenceboy98 wrote: | | I tried that. It didn't work. It said that the variables I reset were unused. | That's a warning that means you're not actually using the variable for anything anywhere. It sounds like you really need to read a C tutorial or two. _________________
 |
|
| Back to top |
|
|
Spenceboy98

Super-Expert

Joined: 06 Jan 2012 Posts: 823 Location: In the TARDIS
|
Posted: 22 Apr 2012 06:27:18 pm Post subject: |
|
|
| I don't know how to tab it. This is so frustrating! |
|
| Back to top |
|
|
christop

Power User

Joined: 09 Mar 2011 Posts: 385 Location: Arizona, USA
|
Posted: 23 Apr 2012 12:47:08 pm Post subject: |
|
|
| Spenceboy98 wrote: | | I don't know how to tab it. This is so frustrating! |
"Tabbing" your code means to indent it so that code at the same "level" is indented by the same amount. For example, the top-level code (eg, #includes and function definitions) should not be indented at all. See http://en.wikipedia.org/wiki/Indent_style for some simple indentation style "rules". There are a few popular different styles, but whichever you use, stick with it. Remember, source code should be readable by humans, and consistency helps.
Any decent text editor (which automatically excludes Notepad) makes it easy to indent your code. I personally use vim and occasionally gedit, but IIRC, you're stuck with Windows, so other people can suggest good text editors that will run (more natively) in Windows. _________________ Christopher Williams |
|
| Back to top |
|
|
Ashbad

... I think redheaded girls are kind of cool

Joined: 01 Dec 2010 Posts: 2417 Location: Stomp Stomp Stomp, The Idiot Convention
|
Posted: 23 Apr 2012 02:01:25 pm Post subject: |
|
|
^ indeed, there is Vim for windows too, but I think that Notepad++ is a great Windows text editor. Some argue Programmers Notepad is a better substitute, but it's hard to go wrong with either one, in my opinion. _________________ -Ashbad |
|
| Back to top |
|
|
Spenceboy98

Super-Expert

Joined: 06 Jan 2012 Posts: 823 Location: In the TARDIS
|
Posted: 24 Apr 2012 10:11:52 pm Post subject: |
|
|
I just tried Kerms input code by itself, but it says,
Code: main.c: In function 'getTextLine':
main.c:13:2: warning: implicit declaration of function 'RTC_GetTicks' [-Wimplici
t-function-declaration]
main.c:51:3: warning: implicit declaration of function 'PrintXY' [-Wimplicit-fun
ction-declaration]
main.c:58:4: warning: implicit declaration of function 'GetKeyWait_OS' [-Wimplic
it-function-declaration]
main.c:59:4: warning: implicit declaration of function 'Bdisp_EnableColor' [-Wim
plicit-function-declaration]
main.c:89:23: error: 'KEY_PRGM_DEL' undeclared (first use in this function)
main.c:89:23: note: each undeclared identifier is reported only once for each fu
nction it appears in
main.c:109:8: warning: implicit declaration of function '_g_strlen' [-Wimplicit-
function-declaration]
main.c: In function 'DrawCursor':
main.c:188:4: warning: implicit declaration of function 'Bdisp_PutDisp_DD' [-Wim
plicit-function-declaration]
make: *** [main.o] Error 1
What did I do wrong? |
|
| Back to top |
|
|
PierrotLL

Advanced Newbie

Joined: 29 Nov 2011 Posts: 71 Location: France
|
Posted: 25 Apr 2012 03:27:03 am Post subject: |
|
|
The only error you have is " 'KEY_PRGM_DEL' undeclared " cause you haven't include the header which define KEY_PRGM_DEL. Search in the PrizmSDK-0.3/include directory, and include the header you need.
All "warning: implicit declaration of function" are also cause you haven't include the right headers.
If you say to a friend to call Bob without giving him Bob's number, your friend can't call him. It's exactly the same for a compiler. _________________ My fx-9860G & Prizm games
My fx-9860G graphic library, MonochromeLib |
|
| Back to top |
|
|
|
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.036639 seconds.
|