Geeks Who Shower



Next Project Revealed
posted October 09, 2006 by eedok
Well I've been thinking a good while and it looks to be that my time would best be invested in writing an engine to speed up the development of future titles. The engine will be primarily built using C++ and SDL, most likely using Lua for scripting. The engine will be an event based engine utilizing a single virtual machine to handle the events. The event structure is based on triggers which is inspired by actionscript.

Technology Used
----
SDL for event handling, and drawing
SDL_image for image loading
SDL_mixer for sound
SDL_ttf for font handling and printing
SDL_net for networking(TCP/IP)
lua for scripting
all these technologies are cross platform to at least windows and linux(my primary platforms) so the games created with this engine should be crossplatform between them. More platforms could possibly be added if I'm able to come into contact with the hardware required to test the application out.

Triggers
----
Triggers must be registered before they can be used, with the exception of these 3:
Code:
OnInit() --Called as soon as the engine has finished initializing
OnEnterFrame() --Called once every frame
OnPaint() --Called before rendering anything to the screen
Keyboard Triggers, called when register_keyboard is true:
Code:
OnKeyDown(key) --Called when a key is pressed, key identifies which key was pressed
OnKeyUp(key) --Called when a key is released, key identifies which key was pressed
Mouse Triggers, called when register_mouse is true:
Code:
OnMouseDown(button,x,y) --Called when mouse button is pressed down, button is which button was pressed, x/y are the coordinates which it was pressed
OnMouseUp(button,x,y) --Called when mouse button is released, button is which button was pressed, x/y are the coordinates which it was pressed
OnMouseMove(x,y) --Called when the mouse is moved, x and y are the new coordinates the mouse was moved to
Joystick Triggers, called when register_joystick is true:
Code:
OnJoyAxisMove(joystick,axis,amount) --Called when an axis on a joystick is moved, joystick identifies which joystick it was, axis is which axis moved and amount is the new position of the joystick axis
OnJoyButton(joystick,button) --Called when a joystick button is pressed, joystick identifies which joystick it was and button identifies which button was pressed
Networking triggers, called when register_networking is true:
Code:
OnConnect(ip,connection_id) --Called when ishost is true and an incoming connection has been made, ip identifies the ip address of the person connecting, and connection_id is a unique identifier for the connection
OnData(connection_id,data) --Called when data is sent to application, connection_id identifies who sent the data and data is what was sent

Built in functions:
Code:
LoadImage(filename):image_id --Loads the image identified by filename, returns image_id for later use
Draw(image_id,x,y) -- Draws an image identified by image_id at the location x,y
DrawString(string,x,y,r,g,b,size) --Draws a string identified by string, at location x,y with color r,g,b of font size size
print(string,timeout) --Prints a string to the screen for timeout milliseconds
Connect(address,port):connection_id --Connects to address/port specified, may get simplified to a single arg of "adress:port" in the future
SendData(connection_id,data) --Sends data to the target identified by connection_id
DropConnection(connection_id) --Disconnects the connection identified by connection_id
SendToAll(data) --Sends data to all open connections
Listen(port) --Set up event handler to listen for connections on port
LoadSound(filename):sound_id --Loads a sound for playing
PlaySound(sound_id) --Plays the sound identified by sound_id
LoadMusic(filename):music_id --Loads music for playing
PlayMusic(music_id,looptimes) --Plays the music looptimes amount of times
StopMusic() --Stops the currently playing music
PauseMusic() --Pauses the currently playing music
ResumeMusic() --Resumes playing music after it has been stopped

Each game will be preceeded by a load script which will be passed these values:
Code:
system.default.resolution --Current resolution
system.default.resolution.w --the width of the resolution
system.default.resolution.h --the height of the resolution
system.default.bpp --Current bits per pixel
system.joysticks --how many joysticks are attached to the system
The load script will be allowed to modify these system variables:
Code:
system.fullscreen --Whether or not to make the game fullscreen
system.resolution --What resolution to use
system.resolution.w -- the width of the resolution
system.resolution.h -- the height of the resolution
system.caption -- The name of the program
system.icon -- The icon for the program
system.capture_input -- whether or not to capture input
system.register_keyboard --register keyboard events
system.register_mouse --register mouse events
system.register_joystick --register joystick events
system.register_networking --register networking events
system.listen --port number to listen on if hosting
system.dedicated_server --if set only networking will be initialized

This is still in the design phase so the above could change at anytime, plus I've never before worked with scripting languages or socket programming so this will be an interesting project in that regard. The two big goals for this project are first off so I can learn both socket programming and scripting and quickly apply them to game development, and to provide a reusable system to quickly prototype game ideas, allowing incoming connections unlike what actionscript allowed. It will primarily be created for myself but there wouldn't be any reason other people couldn't use it(other than the fact I may not document it as good as I could), I have not decided whether or not to make it open source.

Wish me luck
-Cody





Palm game programming
posted September 27, 2006 by eedok
This is a news article that was recovered from the server crash
----
Palm Game Programming
----
One of the big complaints I hear from people after buying a palm is how hard it is to create games for the thing, which is usually followed by the other party agreeing with the statements. Now the toolset that palm actively promotes isn't exactly the friendliest or make much sense for the matter(especially when compared to toolsets offered by the competitors), you don't have to use what palm pushes you to use.

Thankfully there's one of the best kept secrets among those who program for the palm known as plua. In short plua is a customized version of lua 4.0 tailored for the palm. It has 2 modes, first off is a repl mode where you can play around with it, and the second one lets you run files and when you're satisfied with the way they run, you can compile them to a prc which you can beam to others easily.

But how do I make games with this do you ask? Rather than a lengthy explanation I'll give short overly commented examples, and then a link to the documentation:

this first example is a simple demonstration of the way plua handles events in the drawing canvas which you move the pen across to draw and hit a button to clear the screen:
Code:
-- draw.lua
-- Creates a simple canvas to draw on, shows basics of events

-- clear the screen to a blank canvas
pclear()
--loop until the house button is hit
while 1 do
    --wait for an event to occur, the x and y aren't always returned, see documentation for pevent() in the plua docs for more details
    event,x,y=pevent()
    --if the pen is touched to the screen
    if event==penDown then
        --set the pixel the pen is on to the foreground color, sets the cursor position
        pset(x,y)
    --if the pen is moved while touching the screen
    elseif event==penMove then
        --draw a line from the last cursor position to where the pen ended up, moves the cursor to the end of the line
        plineto(x,y)
    --if a button was pushed
    elseif event==keyDown then
        pclear()
    end
end
This second example demonstrates how to have events nonblocking and how to do double buffering in plua
Code:
--bouncingbox.lua
--Creates a box that bounces around the screen

--get the resolution of the device
width,height=pmode()
--create a backbuffer to draw to so the screen doesn't flicker
buffer=pnewbuffer(width,height)
--set the box's starting location
x=random()*width
y=random()*height
--set the speed which the box goes
xmod=1
ymod=1
--loop until home button is hit
while 1 do
    --set drawing to happen on the backbuffer
    pusebuffer(buffer)
    --clear it off to make it ready to be drawn on
    pclear()
    --make sure it's in the screen(doesn't account for width&height for simplicity purposes)
    if x + xmod > width or x + xmod < 0 then
        xmod = xmod * -1
    end
    if y + ymod > height or y + ymod < 0 then
        ymod = ymod * -1
    end
    --move the box
    x=x+xmod
    y=y+ymod
    --draw the box with height & width of 10 to make it easy to see
    pbox(x,y,10,10)
    --set drawing to happen on the screen
    pusebuffer()
    --put the backbuffer on the screen
    pputbuffer(buffer,0,0)
    --not used but wait 1ms for an event to occur before looping
    pevent(1)
end

If you're wondering what a function does in more detail, take a look at the plua documentation, the lua 4.0 manual and some plua samples.

I haven't used plua extensively but I have noticed a couple of drawbacks to it:
1. a millisecond timer doesn't seem to exist
2. you can't change your application icon easily
But other than that game programming for palms doesn't have to be hard.



<< Newer News