Don't have an account? Register now to chat, post, use our tools, and much more.
Online Users
There are 92 users online: 3 members, 82 guests and 7 bots.
Members: tifreak8x, tr1p1ea.
SAX
 » Goto page Previous  1, 2, 3, 4
Author Message
zeldaking

Expert

Joined: 31 Jul 2011
Posts: 604
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._________________

Such ashy church, much Burzum

Joined: 01 Dec 2010
Posts: 2453
Location: There lived a certain man in Russia long ago

 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?_________________IT IS NOTHING BUT BLACK METAL NOVEMBER YOU HAVE NO EXCUSES
Spenceboy98

Super-Expert

Joined: 06 Jan 2012
Posts: 902
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.
souvik1997

Guru-in-Training

Joined: 19 Apr 2010
Posts: 2870

Posted: 22 Apr 2012 06:04:05 pm    Post subject:

 Quote: Code: `if(keydown(KEY_PRGM_EXIT) `

Add a parenthesis to the end of that line.
 Quote: Code: `  }     } `

I'm not sure what that second brace is supposed to match up with.
_________________
CALCnet Tournament-38%

deviantArt

Such ashy church, much Burzum

Joined: 01 Dec 2010
Posts: 2453
Location: There lived a certain man in Russia long ago

 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._________________IT IS NOTHING BUT BLACK METAL NOVEMBER YOU HAVE NO EXCUSES
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
Spenceboy98

Super-Expert

Joined: 06 Jan 2012
Posts: 902
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.

Such ashy church, much Burzum

Joined: 01 Dec 2010
Posts: 2453
Location: There lived a certain man in Russia long ago

 Posted: 22 Apr 2012 06:15:58 pm    Post subject: What type of effect are you going for then, with their movements?_________________IT IS NOTHING BUT BLACK METAL NOVEMBER YOU HAVE NO EXCUSES
Spenceboy98

Super-Expert

Joined: 06 Jan 2012
Posts: 902
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.

Such ashy church, much Burzum

Joined: 01 Dec 2010
Posts: 2453
Location: There lived a certain man in Russia long ago

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.
_________________
IT IS NOTHING BUT BLACK METAL NOVEMBER

YOU HAVE NO EXCUSES
Spenceboy98

Super-Expert

Joined: 06 Jan 2012
Posts: 902
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;      }```

Such ashy church, much Burzum

Joined: 01 Dec 2010
Posts: 2453
Location: There lived a certain man in Russia long ago

 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?_________________IT IS NOTHING BUT BLACK METAL NOVEMBER YOU HAVE NO EXCUSES
KermMartian

Joined: 14 Mar 2005
Posts: 57348

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.
_________________

Spenceboy98

Super-Expert

Joined: 06 Jan 2012
Posts: 902
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!
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

Such ashy church, much Burzum

Joined: 01 Dec 2010
Posts: 2453
Location: There lived a certain man in Russia long ago

 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._________________IT IS NOTHING BUT BLACK METAL NOVEMBER YOU HAVE NO EXCUSES
Spenceboy98

Super-Expert

Joined: 06 Jan 2012
Posts: 902
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?
PierrotLL

Joined: 29 Nov 2011
Posts: 72
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
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
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.

»
 » Goto page Previous  1, 2, 3, 4 Page 4 of 4 » All times are GMT - 5 Hours

 Jump to: Select a forum Announcements----------------Cemetech AnnouncementsCemetech LabsContests General Discussion----------------Technology & Calculator Open Topic-- Electronics/Hardware Development-- Calculator HardwareYour ProjectsGeneral Open Topic-- Politics & Rants-- Reviews-- Humour/Jokes Cemetech's Projects----------------Doors CS and Doors CSESourceCoderMember Features-- TI-Freak8x-- Merthsoft-- GrammerOther & Upcoming Projects-- The BASIC Elite-- mobileTunes-- CALCnet 2.2-- SuggestionsProgramming the TI-83 Plus/TI-84 PlusUsing the TI-83 Plus/TI-84 PlusWebsite Programming & Design----------------General Programmingz80 AssemblyTI-BASICCasio Prizm/FX Development & ProgrammingWebsite Markup & ScriptingGraphics1337 Programming Tips Building with Blocks----------------FreeBuild, LEGO, and Minecraft-- FreeBuild General-- Suggestions & Troubleshooting-- Content & Gallery-- Servers & Activities
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.044663 seconds.