Skip to content

Instantly share code, notes, and snippets.

/*
* HelloWorldAVR.c
*
* Created: 03.06.2015 18:51:15
* Author: Dmitry Victorov
*/
#define F_CPU 1000000UL // ATmega16 Internal clock frequency
#include <stdbool.h>
-(void) update: (ccTime) t
{
// XXX: shall I add % 360
if (_angleX == _angleY)
[_target setRotation:_startAngleX + _angleX * t];
else
{
[_target setRotationX:(_startAngleX + _angleX * t)];
[_target setRotationY:(_startAngleY + _angleY * t)];
}
- (void)update:(ccTime)t
{
NSAssert([_target isKindOfClass:[CCNode class]], @"Target is not CCNode");
// XXX: shall I add % 360
if (_angleX == _angleY)
[(CCNode *)_target setRotation:_startAngleX + _angleX * t];
else
{
[_target setRotationX:(_startAngleX + _angleX * t)];
-(void) startWithTarget:(CCNode *)aTarget
{
[super startWithTarget:aTarget];
startAngle_ = [self.target rotation];
diffAngle_ = dstAngle_ - startAngle_;
}
-(void) update: (ccTime) t
{
[self.target setRotation: startAngle_ + diffAngle_ * t];
-(void) startWithTarget:(CCNode *)aTarget
{
[super startWithTarget:aTarget];
NSAssert([self.target isKindOfClass:[CCNode class]], @"Target is not CCNode");
startAngle_ = [(CCNode *)self.target rotation];
diffAngle_ = dstAngle_ - startAngle_;
}
// Needed to work with attributed strings
#import <CoreText/CoreText.h>
// Somewhere in drawing code, that renders string:
NSMutableParagraphStyle *paragraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
paragraphStyle.alignment = alignments[hAlignment];
paragraphStyle.lineBreakMode = linebreaks[lineBreakMode];
NSDictionary *attributes = @{
// In interface definition
CGPoint *vertices;
CGPoint *coordinates;
// In drawing function
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, coordinates);
NSInteger angle = arc4random_uniform(90) - 45;