Skip to content

Instantly share code, notes, and snippets.

@tiborsimon
tiborsimon / downloader_.css
Last active August 29, 2015 14:15
Customization for the WP-DownloadManager wordpress plugin. The corresponding article can be found here: http://tibor-simon.com/programming/download-system-for-wordpress/
/* Custom download system */
.stdl-page-sum-wrapper {
display: block;
clear: both;
width: 90%;
margin: 0 auto;
}
.stdl-page-sum-element {
display: block;
float: left;
@tiborsimon
tiborsimon / additional_description.html
Created February 16, 2015 11:22
Customization for the WP-DownloadManager wordpress plugin. The corresponding article can be found here: http://tibor-simon.com/programming/download-system-for-wordpress/
<span>DESCRIBE-YOUR-ITEM</span>
<a href="LINK-TO_YOUR_ITEM" title="Corresponding article or portfolio">
DESCRIBE-YOUR-ITEM
</a>
@tiborsimon
tiborsimon / ij2l.m
Created February 16, 2015 11:59
Access upper triangular matrix elements stored in a single row vector - MATLAB implementation - http://tibor-simon.com/programming/access-upper-triangular-matrix-elements-stored-in-a-single-row-vector/
%First create a small function that
function [ l ] = ij2l( i, j, n )
%IJ2L Upper Triangle Matrix Coordinates to Single Row Index
l = j;
for k=1:(i-1)
l = l + (n-k);
end
end
@tiborsimon
tiborsimon / transformation_test.m
Created February 16, 2015 12:00
Access upper triangular matrix elements stored in a single row vector - testing in MATLAB implementation - http://tibor-simon.com/programming/access-upper-triangular-matrix-elements-stored-in-a-single-row-vector/
%% Testing th ij2l function
%% Let the upper trinagle matrix be
%
% | 1 2 3 |
% A = | 4 5 |
% | 6 |
%
% We want to index the second row, last element:
%
void interrupt isr(void) {
// Check the USART transmit flag then the receive flag
if (TXIF) {
...
} else if (RCIF) {
// The control never reaches this branch!
...
}
}
void interrupt isr(void) {
// A very happy ISR
if (TXIE && TXIF) {
...
} else if (RCIE && RCIF) {
...
}
}
private boolean findClosestEnemy() {
if (enemyList.isEmpty()) {
targetEnemy = null;
System.out.println("Target enemy NOT found!");
return false;
}
if (enemyList.size() == 1) {
targetEnemy = enemyList.get(0);
// System.out.println("Target enemy found!");
return true;
...
if (autoAim) {
findClosestEnemy();
if (targetEnemy != null) {
player.setTargetPosition(targetCircle());
}
} else {
if (input.isKeyDown(Input.KEY_T)) {
player.turnLeft(delta);
@tiborsimon
tiborsimon / FieldDirector_calculateAngleForTwoPoints.java
Last active August 29, 2015 14:15
Java Shooter Game - FieldDirector:: calculateAngleForTwoPoints(Circle base, Circle target) - http://tibor-simon.com/programming/auto-aiming-logic-for-games/
public static float calculateAngleForTwoPoints(Circle base, Circle target) {
float px = base.getCenterX();
float py = base.getCenterY();
float ex = target.getCenterX();
float ey = target.getCenterY();
float angle = 0;
...
if (autoAim) {
// determine the rotation direction
float base = image.getRotation();
float d1 = calculateDistance(base, targetAngle);
float d2 = calculateDistance(base-1.0f, targetAngle);
// if the distance is greater than about 3 degree
if (d1 > 0.05f) {