Posts

Deep C.

In this thread I will post interesting features and usages (of mostly the C programming language), that might not be known to a novice programmer. I might figure out how to display code nicely, at some other time.  typedef (declare) a struct name before defining said struct: typedef struct myStruct myStruct; struct myStruct {      myStruct* next      ... };  You can also typedef (declare) a pointer to a struct without defining the struct to achieve type safety (the pointer cannot point to a struct with a different type), and encapsulation (because it doesn't have access to the definition of said struct). Constant on the left!   if(NULL == x){...} is better than if(x == NULL){...} because then you don't get if(x = NULL){...} by mistake Declare type once: struct T *p; p = malloc(sizeof *p); instead of: struct T *p; p = malloc(sizeof (struct T)); Similarly sizeof array = (sizeof (ary) / sizeof (ary[0])) Single item in list or not in any list?

Maths Game.

Image
 I am (occasionally) working on an action RPG game where every time you attack you have to answer a maths question. RPGs are cool and I used to play them a lot but now I am a social gamer and I don't appreciate the brain-drain. I have accrued a large repository of spaghetti code with a few gems as I learn the ins and outs of game programming in C ( https://github.com/BostonBrooks/Spaghetti_Graveyard. ) . I chose C because it is what the electronic and computer engineers use and working as an ECE is a long term goal for me. I am using the C binding for SFML because SDL doesn't easily incorporate 2D meshes, to be used for 2.5D curved ground surfaces. A few demos below. Scritchyness is due to screen capture software.     All for now, Boston.   Update 17/02/2022 In the game, the terrain is represented as a 2 dimensional grid where each point has a third dimension (height). I have used bicubic interpolation (functions with x^3 and y^3 terms) to smooth the areas between points on the

Original Art

Image
 Here is where I will post artwork that is 100% my own intellectual property: I've always been fascinated with things that glow in the dark, such as Christmas tree lights. In the past I've painted a starry night like this. Below are some designs I've made with glowing butterflies. Mr fox is an interesting character from my past. I still use this kind of art style for characters in the game I'm making.   All for now, Boston Update 20 / 6 / 2022 Here are some things I made at pottery with mum: Broken Mushroom: Update 05/07/2022: I made a mould of my clay tortoise and made a plaster copy: Update 08/05/2022: I carved out the bottom mould so that the head will stop getting stuck in there and breaking off. Now I don't have enough liquid silicone to make a new top mould... Update 27/03/2024 It's been a long time since I posted an update. Here are some photos of my experiment with using a vacuum chamber to suck the air out of a mold and then have that space being rep

Coffeyy

 I love coffee. When I was in high school I used to drink a lot coffee and chicory essence iced coffees. Then I matured to "normal coffees", which are made from boiled water, coffee powder and dairy milk.  I have a friend who drinks coffee with plant based milk, I'm curious as to why, I'll have to ask them. I just let the beans do the talking. Half of the time the coffee just meets the minimum standard for how coffee should taste, but sometimes its like, "Ooh, that tastes like walnut," and it makes it all worth it.  Another friend of mine saw me making a coffee in the usual way and she told me I had to add the milk first before the boiled water, so I just had it black. I've worked at cafe's and made coffee for myself and I've always put the milk in last. Only one time have I scolded the milk and that was from using the milk frother, not from adding milk to boiled water.  So, I went around drinking black coffee, but the weather was too hot, so I s

Android Lecture Notes App.

Image
I seem to be bouncing around between different projects, some projects require time e.g. waiting for glue to set, some are on the back-burner because there's only so much time in a day. With this new project, I am working on a vector drawing app for taking lecture notes on a smartphone or tablet. You will be able to zoom in and out on a massive canvas and write fluidly with a stylus pen. I've downloaded Android Studio and I'm working through the basic features of a Hello World app. I am unfamiliar with Java and using an IDE, so the next month before I start uni will be fun. PS I am enrolled in a Graduate Diploma of Science in Applied Maths at the University of Queensland, starting in one month's time. Update 25/6/2022 Here is a screenshot of a program I copied off YouTube. This app draws directly to the screen. Mine will draw to a scroll-able canvas.   Update 8/7/2022 I taken a template app with a main screen and a settings screen and rolled in the code I had for drawin

Friedrich Nietzsche

Image
  Friedrich Nietzsche was a philosopher in the 19th century. I find his work inspirational and life affirming. Nietzsche's book  Also sprach Zarathustra: Ein Buch für Alle und Keinen has two translations, Thus Spoke Zarathustra and Thus Spake Zarathustra. Thus Spoke Zarathustra is written in relatively modern English and Thus Spake Zarathustra is written in biblical English. I have read Thus Spoke Zarathustra and now I am reading Thus Spake Zarathustra. I thought Thus Spake Zarathustra would be more impactful because of its biblical style, but I'm finding it less impactful because of the less direct language and the distraction of having to mentally translate the book into modern English.  Thus Spake Zarathustra uses the term Superman whereas Thus Spoke Zarathustra uses the term Overman. The word Superman has been diluted by popular culture and I feel the word Overman better captures the feeling of Nietzsche's Ubermesch, the successor that rises above mankind. I will contin

Isomorphic Keyboard

Image
 I've been researching how to make an isomorphic musical keyboard. This keyboard will be laid out like a computer keyboard where you form the chord shape with your fingers and move left and right on the keyboard to choose the key. The actual keys will be arranged so that if you go one key to the right, you go up one note on the musical scale, if you go up and to the left or up and to the right you go up three or four notes; the major and minor third harmonics. This is the whole reason I purchased a Raspberry Pi and an FPGA, and I'm thinking of buying a single board computer with built-in FPGA after I have a working prototype. I have tried to install a musical synthesizer library for C, but I haven't quite got it working, and its been a while.     Image: Isomorphic Keyboard. All for now, Boss It turns out that if you ignore the accidentals on a regular keyboard, the four standard chords all look the same. I wish I knew this when I owned a keyboard.  I guess I won't be bu