• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
lvnt

reni2D library - (added shader support,pixel perfect collision)

3 posts in this topic

Hi,
I'd like to share the 2D library we started using at our college for beginner and advanced programming students.
Students find it easy to use and seem to get quick results.
It is written in C using OpenGL,

It is very new, I update it quite often, download it from here for newer versions
http://involuntaryexercise.com/apps/reni2d.zip

added: very easy to use pixel shader support, see example code
added: fast pixel perfect collision detection
check out example code

feature list:
- very clean and straight forward api
- simple and plain state machine
- no classes, no inheritance, no custom data types, no constants

- hardware accelerated 2D sprites
- pixel perfect collision detection (can be batched and baked)
- easy to use pixel shaders
- alpha blending and tinting
- texture sampling operations (easy tiles,sprite/font sheets,sliding)
- mouse and keyboard input (including hardware polled mouse movements)

- random numbers, rotation operations, bitmap loading


edit:
I finally tested reni2D's performance against something out there.
I hear a lot about Haaf's engine, so I took his "Thousands of Hares" example and replaced drawing calls with reni2D. Test app is running 2000 sprites by default, "SPACE KEY" flips between blending mode 0 and 2.
http://hge.relishgames.com/doc/html/tutorials_tut07.html
It performed great, even slightly faster. Here is the test executable,images and the ported example code:
http://involuntaryexercise.com/apps/reni2dhgetest.zip
mode 0

mode 2


here is all the code needed to create the following effect:

unsigned int s=raGetShader("raColor.xyz = raArg0.z*raColor/distance(raArg0.xy,raPixelPos.xy); ");
raSetShader(s);







shader test screen shots (20000 sprites!)- lighting




here is the entire code for the example image:



#include "reni2D.h"
int RA_MAIN() {
unsigned int betty = 0;
float x,y;
float a=0;
//init engine
raInit(800,600);
//load sampler
betty = raGetSamplerFromFile("betty.bmp");
raSetSampler(betty);
//white opaque color multiplier
raSetDrawColor(255,255,255,255);

while(raRun()) {
raClear();

//draw 64x64 quad
raSetQuadSize(32,32);
raSetQuadRot(-90);
//big betty, at center, rotated -90 around origin
raDrawQuad(400,300);

//using dummy point to do pivot rotation of 45 degress 50 units from origin
raResetDummy();
raMoveDummy(50,0);
raRotateDummy(a);
a+=0.5;
//resulting coordinates are based on 0,0 , now move the altered dummy to center of screen
raMoveDummy(400,300);
//get the results
x = raGetDummyX();
y = raGetDummyY();
//small betty
//draw 16x16 quad
raSetQuadSize(8,8);
raSetQuadRot(45);
raDrawQuad(x,y);
}

}















If you have time, please give it a try and throw some feedback,
Thanks
Levent

(edit4: api overhaul reflected in example code)

[Edited by - lvnt on November 2, 2010 5:29:58 PM]
0

Share this post


Link to post
Share on other sites
What I'm wondering about this code, is if the canvas on a sprite is in the exact middle or one of the corners. I'm asking this in order to try and make a collision algorithm that can detect both horizontal and vertical at once.
0

Share this post


Link to post
Share on other sites
Hi, let me try to give you an example,

When you issue the following:

raSetQuadSize(32,32);
raDrawQuad(400,300);

you are drawing a 64x64 sprite, centered at 400,300. (using half width and height)

coordinates for vertices in CCW order are:

TOP_LEFT : 400-32,300+32
BOTTOM_LEFT : 400-32,300-32
BOTTOM_RIGHT: 400+32,300-32
TOP_RIGHT : 400+32,300+32

more info and detail:

very basic sprite example

//example sprite class
//not including texture work
typedef struct _spr {
float x,y,r,w,h;
}spr;

//draws sprite centered at canvas, rotated around own origin
void sprDraw(spr *s) {
raSetQuadSize(s->w,s->h);
raSetQuadRot(s->r);
raDrawQuad(s->x,s->y);
}


sprite using single texture

//example sprite class
//sprite has own texture
typedef struct _spr {
float x,y,r,w,h;
unsigned int tex;
}spr;

//draws sprite centered at canvas, rotated around own origin
void sprDraw(spr *s) {
raSetSampler(s->tex);
raSetQuadSize(s->w,s->h);
raSetQuadRot(s->r);
raDrawQuad(s->x,s->y);
}


sprite using sprite sheet


//example sprite class
//sprite uses sprite sheet
typedef struct _spr {
float x,y,r,w,h;
float u,v,uw,uh;
}spr;

//draws sprite centered at canvas, rotated around own origin
//assume sprite sheet (sampler) is set before drawing set of sprites/animations
void sprDraw(spr *s) {
raSetSamplerArea(s->u,s->w,s->uw,s->uh);
raSetQuadSize(s->w,s->h);
raSetQuadRot(s->r);
raDrawQuad(s->x,s->y);
}


[Edited by - lvnt on October 24, 2010 4:52:15 AM]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0