I am just getting started with C, so I thought I'd create this thread to keep people updated on my progress and use the thread if I have any questions. It is long overdue that I move on from TI-Basic, so I will be trying to avoid doing any other big projects in that language from now on. I already have a bit of experience in computer C programming from the previous school year, but it was specifically for simple input/output within the IDE. This thread is dedicated to my CE C programming in general.

I already have my directory set up including the toolchain, so it is easy to create however many programs I want from the template. So far I have made a simple home screen text output program, as well as a movement program for the home screen which allows you to control a character "O" within the 10x26 bounds. My next idea is to try a fruit-ninja swiping test program, similar to the TI-Basic one I made but improved.
Good luck with this, you've made incredible programs in BASIC so I'm really looking forward to seeing what you can do with C!
Fruit ninja CE sounds like a fun project, I tried to recreate it in ICE a long time ago but it fell to the wayside when I started my HDpic project again. I can share some of the code if you'd like. Smile
Thanks! Well as I said I'm a bit new to this, so I have some questions that may seem simple but:

1. Should I or should I not use the os_GetCSC() input for getting a stream of key presses into a list from a finger swipe across the keyboard?
2. If not, then how exactly would I do this? Keep in mind, even TI-Basic worked very fast and accurately for the most recent test program I made. I just need some help getting key swipes into a list.
3. Perhaps a very very simple question but If I am storing the result of os_GetCSC() to key, what value/result is in variable key if nothing has been pressed? Or is it enough to say "If (key) { ... }"? Or "If (key>0) { ... }"?
1. Use kb_Scan().
2. Use kb_Data.
3. See above.
I am making slow progress, I know it's been a few days but I'm trying to figure out the keypadc.h library/header... perhaps if someone is willing, the wiki can have more examples on it sometime?

Right now I am stuck on getting a unique key code into a variable so I can turn it into a coordinate on the graph screen. Yes I've looked at the wiki, yes I've looked at the header documentation but I still haven't been able to do what I want. Any help?

Also, how might I tell if a key pressed is the [math] button or beyond?
Have you even looked at any of the examples? That's what they are for.
So..... progress! This uses [math] in the top left through [enter] at the bottom right.


But... terribly unoptimized code

Code:
/*
 *--------------------------------------
 * Program Name:CSWIPE
 * Author:Michael2_3B
 * License:MIT
 * Description:An experimental C program to swipe like you do in fruit ninja.
 *--------------------------------------
*/

/* Keep these headers */
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <tice.h>

/* Standard headers (recommended) */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Other headers I included */
#include <graphx.h>
#include <keypadc.h>

/* Put your function prototypes here */

/* Put all your globals here */

void main(void) {
    /* Fill in the body of the main function here */
    kb_key_t key;
    //int myList[];
    int i=0;
    double x;
    double y;
    gfx_Begin();
    gfx_FillScreen(gfx_white);
    gfx_SetColor(gfx_blue);

    do {
       kb_Scan();
       x=0;
       y=0;
       if (kb_Data[2]) {
          key = kb_Data[2];
          x=32;
          if(key == kb_Store)
             y=188.573;
          if(key == kb_Ln)
             y=154.287;
          if(key == kb_Log)
             y=120.001;
          if(key == kb_Square)
             y=85.715;
          if(key == kb_Recip)
             y=51.429;
          if(key == kb_Math)
             y=17.143;
       }
       if (kb_Data[3]) {
          key = kb_Data[3];
          x=96;
          if(key == kb_0)
             y=222.859;
          if(key == kb_1)
             y=188.573;
          if(key == kb_4)
             y=154.287;
          if(key == kb_7)
             y=120.001;
          if(key == kb_Comma)
             y=85.715;
          if(key == kb_Sin)
             y=51.429;
          if(key == kb_Apps)
             y=17.143;
       }
       if (kb_Data[4]){
          key = kb_Data[4];
          x=160;
          if(key == kb_DecPnt)
             y=222.859;
          if(key == kb_2)
             y=188.573;
          if(key == kb_5)
             y=154.287;
          if(key == kb_8)
             y=120.001;
          if(key == kb_LParen)
             y=85.715;
          if(key == kb_Cos)
             y=51.429;
          if(key == kb_Prgm)
             y=17.143;
       }
       if (kb_Data[5]) {
          key = kb_Data[5];
          x=224;
          if(key == kb_Chs)
             y=222.859;
          if(key == kb_3)
             y=188.573;
          if(key == kb_6)
             y=154.287;
          if(key == kb_9)
             y=120.001;
          if(key == kb_RParen)
             y=85.715;
          if(key == kb_Tan)
             y=51.429;
          if(key == kb_Vars)
             y=17.143;
       }
       if (kb_Data[6]) {
          key = kb_Data[6];
          x=288;
          if(key == kb_Enter)
             y=222.859;
          if(key == kb_Add)
             y=188.573;
          if(key == kb_Sub)
             y=154.287;
          if(key == kb_Mul)
             y=120.001;
          if(key == kb_Div)
             y=85.715;
          if(key == kb_Power)
             y=51.429;
          if(key == kb_Clear)
             y=17.143;
       }
       if(x>0 & y>0){
          gfx_Circle_NoClip(x,y,10);
          i=0;
       } else {
          i++;
          if(i==500)
             gfx_FillScreen(gfx_white);
       }

    } while (kb_Data[1] != kb_2nd);
   
    gfx_End();

}
Whenever I run my program, the sprites I've made all come out in varying shades/brightnesses of green. Now that I have 4 more sprites, all of them look different than what they should.

I initially thought this was a convpng issue with not processing colors correctly, but then I realized it worked fine on the watermelon earlier. Anyone know what's wrong?

EDIT: Nevermind. I forgot to set the palette.
  
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
Page 1 of 1
» All times are UTC - 5 Hours
 
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

 

Advertisement