Vietnam’s Fire Spitting Dragon Bridge

In honor of the 38th anniversary of the end of the Vietnam War, Da Nang City unveiled a 666 meter-long dragon-shaped bridge on Friday, April 5, 2013.[1]

Designed by the Louis Berger Group the six-lane bridge emulates the shape of the dragon in the Ly Dynasty.[2]

Here you can see the Dragon Bridge in action: video.

(Sources as indicated)

Bridges ♦ Bridges on facebook

What do you think?


so damn cool :3

Back to Basics of Programming (Structures)

As I start my journey on MCPD it’s awesome to learn little things for the first time as well as relearn again some things that I haven’t had to think about in a long time due to lack of use in my everyday programming.

On of the things I that I’ve vaguely heard about before but never went further with is the user-defined type called Structures or simply Structs. While in today’s apps you rarely if ever use them anymore they could still be useful for mobile apps where you may need to watch overhead more than for a windows or web application. 

It was interesting to learn that you can on a basic level swap out the class keyword for the struct keyword and your code will still work (sort-of). Please note though that this is only possible with simple classes that are not doing much internal processing.

A key point to note about structs is that they are more efficient than classes because they are smaller in memory and run on the stack.

The times you many want to use a Struct over a class is:

  • Represents a single value logically
  • Has an instance size of less than 16 bytes
  • Is not frequently changed after creation
  • Is not cast to a reference type.

As a final note structs are good in situations when you just need to encapsulate data with out needing additional “functionality”.


Article regarding mutable structs and code optimization

C# programmers!

Couple of fun links for considerations to make with regards to structs. But first:

One of the most widespread design conventions is that you should prefer to use public properties, instead of fields. Why?

There are many resources on the subject, but it boils down to having more robust and consistent code. For example, if you’re designing a library or framework, clients to your code will have to recompile if you switch from a field to a property. Not very user friendly. You can also do cool stuff like attach logging to the getter, or slap a debug breakpoint to the setter. With fields, you can do this as well, but you can’t enforce it, and at best, it’s a hackish solution.

The other thing is regarding structs. In most cases, you don’t need to make your own value types. Remember that they are supposed to indicate values, not objects. A point (1, 1) is the same as B point (1, 1). They are 100% identical. My red hat and your red hat, even if they rolled off the assembly line together are completely unique. However, when writing graphics libraries or working with low-level code, you’ll probably end up making a few.

One of the reasons against writing value types is their semantics. Whenever they’re passed around (retrieving it from an object, passing it into a method) a full copy is made; this can confusingly make it so that the copy is modified instead of the original object. There are ways around this, such as making structs mutable, or using the ref or out keyword, but in 99.9% of the cases (ie, yours) it’s simply easier to just don’t do it.

Having said that, I invite you to look at the following links regarding code optimization. In the very first example, the author breaks three rules by making a public mutable value type larger than 16 bytes. But, because he understands the ramifications of doing so, and it’s a performance optimization for graphics programming, it’s pretty obvious that this is okay in this instance.

Anyways, food for thought:

Interating through an array of structs

Interating through an array of structs

I have a very specific problem I am trying to solve. I have an array of structs containing product information. Each struct has the following information.

Supply type
product name
wholesale price
quantity of wholesale
retail price
retail product quantity

My array of structs is complete and that is fine and dandy. Now, let’s say there are a couple of supply types such as:

Fruit etc……

View On WordPress

Week 6: Structs, classes lists and arrays

This week we have a busy week with three different topics, although I’ve already done two of them which are lists and arrays, but it must go on.

To start we had structs, be compared it to C and C++ and how they work differently across these different languages which are in the same ‘family.’ Before classes there were only structs, in languages such as C there are no classes there are only structs, structs just acted as a way to group data together so it could be treated as a whole or to add structure hence 'struct.' Structs layouts are the same as classes, so that’s what we looked at next, their layout, we then looked at their limitations and the point when classes came along.The difference between the two is that structs are value types and classes are reference types, structs cannot have a null reference where as classes can.


 Moving on to lists and array after that huge chunk of text on structs. These are both used in the same way but the major difference is that an array cannot be resized where as a list can. We then looked at the differences, or lack there of, between the two and how they both work (with some fancy diagrams), we then looked at their usage and how the reallocation of a list works.

And that’s week 6 done, tune in for next week’s.

C++: Functions in Structs

Apparently you can define functions in structs, like so:

struct node {

   int key, value;

   node(int k, int v) : key(k), value(v) {};  //constructor

   int getKey() {return key;}; //function


Watch on

Structs in C: Computer Programming 9: 24HourAnswers Tutorials

Created for u000aThe computer programming tutorial you are about to see is one in a series developed by 24 hour answers, with the idea of helping students learn in a simple, easy, and convenient format.u000aToday we examine structs.

Wrestling with Class

Taken from the MSDN ref site:

Classes and structs are two of the basic constructs of the common type system in the .NET Framework. Each is essentially a data structure that encapsulates a set of data and behaviors that belong together as a logical unit. The data and behaviors are the members of the class or struct, and they include its methods, properties, and events, and so on, as listed later in this topic.

A class or struct declaration is like a blueprint that is used to create instances or objects at run time.

A class is a reference type. When an object of the class is created, the variable to which the object is assigned holds only a reference to that memory. When the object reference is assigned to a new variable, the new variable refers to the original object. Changes made through one variable are reflected in the other variable because they both refer to the same data.

A struct is a value type. When a struct is created, the variable to which the struct is assigned holds the struct’s actual data. When the struct is assigned to a new variable, it is copied. The new variable and the original variable therefore contain two separate copies of the same data. Changes made to one copy do not affect the other copy.

In general, classes are used to model more complex behavior, or data that is intended to be modified after a class object is created. Structs are best suited for small data structures that contain primarily data that is not intended to be modified after the struct is created.

structs asked:

tequila é pra elas

teu tumblr: maravilhosamente maravilhoso, textos lindos, conteudo fantástico, theme perfeito. te segui!

rebloga um quote meu, manda na ask “tequila é pra elas” que eu avalio e reblogo duas autorias suas, go

TowerFall Physics

I get a lot of questions about how the physics work in TowerFall. It’s a very simple system I arrived at after about a decade of experimenting with tile-based platformers. I wrote an engine ages ago for Game Maker games that uses the same basic concepts, and since then I’ve simplified and improved it a bit. Also, TowerFall’s engine is written in C# so we have fancy features like delegates and structs that make everything nicer. It’s nothing ground-breaking, but I decided to write it down in case it helps anyone!

Keep reading

No, marriage is not “a union between husband and wife”.

It’s more like a struct.

This is an important point. See, you can start with

struct marriage {
    t_man husband;
    t_woman wife;

and when enlightenment hits, you can update to

union person { t_man man; t_woman woman; };
struct marriage {
    union person partner_a;
    union person partner_1;

and retain some degree of binary compatibility.

But adding a third member to the marriage? You’d definitely have to recompile everything.

Checkmate, polyamorists.


I got the most important part working now it’s just adding features.

How it works (or will work for some parts) [edited]

Three 32-bit render textures/render targets:
1 On screen, the one you actually draw on, it is not cleared every frame, only when needed, you just keep drawing over it (or erasing)
1 On screen for onion-skinning, drawn before the main canvas
1 Off screen, will be used to render every frame of an animation into separate png files without using the main canvas

Just a textured quad you can scale and apply any texture to. You draw the brush quad on the canvas texture. With the WinTab API you can use tablet pressure to scale the image. Examples in the images above.

How it’s rendered on screen
You record the mouse/tablet input and store it. The data structure I use (plain C struct) just stores mouse coordinates, the brush texture (ID), the colour, the scale and other basic info.

Rather than store the canvas image you store the input so you can save/load and recreate any image by going through the input list and drawing that to the canvas. Every animation frame just stores a  list of all the brush strokes.

This is needed because render targets can get destroyed/lost and if you didn’t save that to a file you lose your drawing! Now if anything happens you can recreate the image with the input.

Continuous lines
Take the last input and current input position and draw brush strokes between them, you don’t store the in-between points but you do render them on screen or else you get gaps between points at long distances.

If you move your mouse/tablet pen quickly and far it won’t give you many input points so you have to fill it in yourself.

If you want to go fancy you can draw curves between those points to avoid all those straight lines but in my case this isn’t important.

Output images
When you need to render the animation to external files you use the off screen render target, render the frame using the input list, save the image and continue until you reach the last frame

Eraser brush
Erasing is just an alpha blending operation applied when rendering the brush quad.
The formula for that is:
source color * 0 + destination color * (1 - source alpha)

Pixel art animations
It could also be used for pixel art, just use a lower res render target (like 256x256 for example), disable bilinear filtering to get rid of blurring, and use integer scaling when zooming so it doesn’t get distorted.

More features
There’s a billion features you could add but I’m only adding what I need or else it’ll just fall into a hole of feature creep. Next step is animation.