Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - eric22222

Pages: [1] 2
Game Development Artistry / Pixel Genie
« on: 2017-05-26, 06:42:11 PM »
Hey all! I've been working on a site for churning out quick, decent-looking tiles for another project. After a little spit and polish, I've got it usable for the masses. Maybe someone here can get some use out of it. I built it with color tiles like below in mind, but I tweaked it to allow for UV map generation which would come in handy for SGDK 2.3!

Check it out here: Pixel Genie

Here are some examples of the tiles it spits out:

General Discussion / Node with SGDK2
« on: 2015-03-19, 09:26:28 PM »
Hey all, I've been tinkering with networked games through sgdk, and I think what I've stumbled through will help anyone else out who might want to take a stab at it.

Node.js is a fun program that makes it pretty easy to run a server in javascript. This makes it good for plugging in to sgdk's HTML5 projects since they're based on javascript. The tricky thing with networked games is that the server and the client have a communication delay between them, so you can't very well run every frame on the server and send the results back to the client. It's much smoother to have both the client and server run the same game code, and synchronize periodically. I managed to get Node to accept sgdk's generated javascript as a module, but it doesn't like running it. Node runs through the console, which means there's no document or window object to reference. So here's how you can do it!

Set up your node directory like this:

NodeFolder (folder)
- myServerCode.js
- node_modules (folder)
- - sgdk (folder)
- - - index.js
- - - sgdk-lib (folder)
- - - - sgdk.js
- - - - sgdk-extend.js

myServerCode.js is your Node application. Do whatever you want here, and add these lines:

Code: ("myServerCode.js addition") [Select]
var sgdk = require('sgdk');

index.js is what ties all the files in the sgdk module back to Node:

Code: ("index.js") [Select]
var fs = require('fs');
filedata1 = fs.readFileSync('./node_modules/sgdk/sgdk-lib/sgdk-extend.js','utf8');
filedata2 = fs.readFileSync('./node_modules/sgdk/sgdk-lib/sgdk.js','utf8');
exports.startGame = startGame;
// This tells Node that the function startGame is to be exported and made accessible to the server code

sgdk.js is just the generated javascript file exported from the HTML5 project. I had to replace
Code: ("sgdk.js original") [Select]
mainLoop.interval = setInterval("pulse()", mainLoop.milliseconds);with
Code: ("sgdk.js edit") [Select]
mainLoop.interval = setInterval(pulse, mainLoop.milliseconds);
Finally, add sgdk-extend.js to dummy out the drawing functions in a mocked document/window:

Code: ("sgdk2-extend.js") [Select]
var document = new mocument();
document.elements = new Object();
document.elements['gameView'] = new mockGameView();

function mocument() {}
mocument.prototype.write = function(x) { console.log(x); }
mocument.prototype.getElementById = function(x) { return document.elements[x]; }
mocument.prototype.createElement = function(x) {}
mocument.prototype.querySelector = function(x) { return null; }

var window = new Object();
window.innerHeight = 768;
window.innerWidth = 1024;

function mockGameView() {}
mockGameView.prototype.getContext = function(x) { return new mockCanvas(); }

function mockCanvas() {}
mockCanvas.prototype.fillRect = function(x,y,w,h) {}
mockCanvas.prototype.strokeRect = function(x,y,w,h) {} = function() {}
mockCanvas.prototype.beginPath = function() {}
mockCanvas.prototype.rect = function(x,y,w,h) {}
mockCanvas.prototype.clip = function() {}
mockCanvas.prototype.restore = function() {}
mockCanvas.prototype.drawImage = function(i,x,y,w,h,x2,y2,cw,ch) {}

And voila, sgdk in a console!

(This is pretty much just a single sprite with initial velocity heading for a dead end, so no player input from the console)

You can add other exported functions so that you can perform game logic based on network communication. For instance, have the player send its position to the server every so often, and respond with the location of all other sprites. Hope this helps!

Projects / Runaway Rabbit
« on: 2014-07-30, 08:36:28 PM »
Hello everyone!

It's been a very, very long time since I've submitted a game here. I've been working on this project on and off for a few months, and it's finally polished up and ready to play! It's only demo-length, but I may add more levels in the future.

Runaway Rabbit (40 MB exe w/dlls)
Runaway Rabbit source (42 MB sgdk2)

+ A: Move left
+ D: Move right
+ W: Enter level
+ SPACE: Jump
+ P: Pause game

While paused:
+ S: Save game
+ L: Load game
+ Escape: Resume game

Weapons unlocked in the shop after level 4:
+ Cycle weapon - mouse scroll wheel
+ Draw weapon - hold left mouse button
+ Fire weapon - release left mouse button

Help, Errors, FAQ / Check for mouse wheel scroll
« on: 2014-04-26, 01:54:57 PM »
Is there any method built-in that will let me check if the mouse wheel has been scrolled? IsMouseButtonPressed let's me check if the mouse wheel is clicked, but I'm looking for scroll up/down events.

Help, Errors, FAQ / Change sprite draw order
« on: 2014-04-09, 09:22:06 PM »
Hey guys, anyone know of a good way to change the order spirtes within a layer are drawn? I'd like to keep my player on top, but it seems to draw from oldest to newest. Didn't find anything in the layer base file, but I may not be looking hard enough. Thanks!

Script / StopClip
« on: 2007-12-23, 12:09:53 PM »
With a difficult semester behind us, Adam and I have picked back up on our project, Zinc. I created a pretty spiffy pause screen, and would like to get to it pretty quickly, that is, without waiting for the music to fade out. Since the pause button is scripted, I figured it'd be easier to simply tell the game to quit playing the music rather than go through a complicated string of special functions with assigned media. Here's what I've got:

Code: [Select]
Of course, I wouldn't be posting this if all went as planned. I wind up with this error:

Code: [Select]
Argument not optional: 'ProjectObj.MediaMgr.Clip(...).StopClip'
If anyone has any idea on what the problem is and how to fix it, it'd be much appreciated.

Script / Side swapping
« on: 2007-05-02, 08:24:29 AM »
Little background info here: as you may remember me saying, the planet where our game takes place is tidally locked to its sun. The level I'm working on is a mountain range halfway across the planet. One side is covered in vegetation, the other is bare rock. The feature I thought up for this is being able to swap back and forth from side to side by pressing shift. (A quick picture is here)

This is the piece of code that's activates when the player presses shift:
Code: [Select]
With ProjectObj.GamePlayer.PlayerSprite
 If NOT (.rDef.SolidTest((-.X+9568), .Y) OR .rDef.SolidTest((-.X+9568), .Y+31) OR .rDef.SolidTest((-.X+9599), .Y) OR .rDef.SolidTest((-.X+9599), .Y+31))Then
  .X = -.X + 9568
  .DX = -.DX
  If left(.rDef.Name,14) = "Player_jumping" Then
   Direction = -Direction + 1
  End If
  If (.rDef.Name = "Player_"+MapNum) OR (.rDef.Name = "Player_spear_"+MapNum) Then
   If (.CurState MOD 2) = 0 Then .CurState = .CurState + 1
   If (.CurState MOD 2) = 1 Then .CurState = .CurState - 1
  End If
 End If
End With

Now the trouble is, every once in a while (and only while moving right), the swap function crashes the game, giving me "subscript out of range". Any ideas will be helpful.

Off-Topic / Portal
« on: 2007-04-30, 06:13:30 PM »
Check this out: this fall, Half-Life 2: Episode Two is set to be released. Coming with it is a game called Portal. The genre itself is enough to draw my attention: a first person puzzle game. The idea is that you can use a device to shoot two portals into walls. The result is, obviously, a portal perfectly connecting the two impact points. Light, momentum, gravity; it's all taken into account.

I'm not too up-to date on Half-Life, so I probably won't end up getting Portal. Still, Portal does look cool. Check out the gameplay video.

Projects / Zinc
« on: 2007-02-04, 07:52:06 PM »
We've named our main character, though not the actual game. He'll be called Zinc, and the game will probably be Zinc's Adventure, or Zinc's Quest, something like that. I realized I still haven't posted any screenshots yet, only a tileset which hasn't actually been used. So here's a preview. The plus of a movie is you can see the parallax in action, along with how the player moves. Only downside is terrible sound quality. Still, you get the idea from this.

The movie!

Questions, comments, and suggestions welcome!

Edit: the video may take a bit of time to go live. If you're getting some errors from Google Video, try back later.

Help/FAQ / Saving & Script
« on: 2007-01-18, 10:47:07 PM »
Well, we've made a lot of progress, but now I'm having trouble with my game saving stuff. What I noticed is this: when I tried to load a game in the 2nd map (where I created the definitions), I got an error saying it couldn't find a template. After a little more trial, I found it would load everything in the first map (where it's all predefined), but I got a little strange behavior. The ability to throw the spear is dependent on a variable (have_spear). I found that when I load the game, I can't throw it.

What all this leads me to believe is that the script variables aren't saved with the game. (A) Is this the case, and (B) how do I fix it?

Off-Topic / Happy Birthday!
« on: 2007-01-01, 11:01:41 PM »
Hey, bluemonkmn! Have a happy birthday!

I attached a birthday photoshop image, btw.  :D

Script / Sprite Definition Creation
« on: 2006-12-27, 11:38:57 AM »
Okay, I've gotten the art of creating sprites in script under my belt. Now it's high time I learned how to create sprite definitions in script. I'm starting out by just trying to create one sprite definition. Once I get that figured out, I'll rewrite this loop to include all the sprites I want to copy. Here's my plan: I'll go ahead and create all the player and weapon sprites that will be need for each map. I'll trigger this sub to copy all the sprite definitions:

Code: [Select]
Sub CopySprites
   With ProjectObj.Maps("Home_Mesa_Interior")
      dim I
      I = 0
      Do While I < .SpriteDefCount
         If .SpriteDefs(I).Name = "Player_jumping_right_1" Then Set NewJumpLeftSpr = .SpriteDefs(I).Clone
         I = I + 1
   End With
End Sub

Then, whenever the player gets to a new map, I'll trigger this sub to put all those sprite definitions into the map:

Code: [Select]
Sub LoadSprites
   With ProjectObj.Maps("Home_Desert")
      Set NewJumpLeftSpr.rPath = .Paths(1)
      NewJumpLeftSpr.Name = "Player_jumping_right_6"
      Set NewJumpLeftSpr.Template = .SpriteTemplates("Player_jumping_right")
      .AddSpriteDef HostObj.AsObject(NewJumpLeftSpr)
   End With
End Sub

Problem is, once the player is supposed to change over to the jumping sprite, he just kinda disappears... That's telling me I have created a definition (since I would otherwise get an error), but sort of an empty shell of a definition. The map where I'm loading the sprite definition has a template named Player_jumping_right already. It usually changes to a sprite named Player_jumping_right_2, but I'm manually making it try to change to _6 to test if the definition is being made.

The scripts I'm looking at for this are GoldYoink and Wudd, both of which do way more object creation than I plan on, so maybe that's where I missed something. Any help will, as always, be greatly appreciated.

Script / OnTileInteraction
« on: 2006-12-23, 02:48:31 PM »
Could someone explain some of this? I know what bNewTouch and InteractionIndex are referring to, but the other values, I'm a bit uncertain:

Sub Player_OnTileInteraction(TileX, TileY, TileValue, bNewTouch, InteractionIndex)

Out of all the projects I've downloaded, GoldYoink is the only one using this sub, and it doesn't have but 4 or 5 lines of code in it.

What I'd like to do is check the name of the category that triggers an interaction, but I don't know if that can be done. If not, I'll just check the actual tile (once I know what those first three above mean) and then the tileset.

Script / Functions in Script
« on: 2006-12-14, 11:08:09 AM »
Alright, I'm having more script problems. We have our player throwing a spear at an enemy. There's a collision between the two sprites, and I want to activate a function in script that will create a death animation sprite based on the enemy that was killed. Here's what I've got:

Code: [Select]
Dim SprDead

Sub Player_OnSpritesCollide(Name, ClsASprIdx, ClsBSprIdx, CollDefIdx)
   Dim SprA, SprB
   Set SprA = ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.Sprite(ClsASprIdx)
   Set SprB = ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.Sprite(ClsBSprIdx)
   If CollDefIdx = 1 Then
      If left(SprB.rDef.Name, 4) = "Slug" Then
         KillSprite (ClsBSprIdx)
      End If
   End If
End Sub

Function KillSprite (SprDead)
   Dim X, Y
   Dim NewSpr, Lyr
   X = SprDead.X
   Y = SprDead.Y
   Set Lyr = ProjectObj.GamePlayer.rmap.MapLayer("Main")
   Lyr.RemoveSprite SprDead
   If left(SprDead.rDef.Name,4) = "Slug" Then Set NewSpr = Lyr.pMap.SpriteDefs("Dead_Slug_" + MapNum).MakeInstance
  NewSpr.X = X
  NewSpr.Y = Y
End Function

I get an error message saying "Object required: SprDead." From what I understand, it should have the value from where I pass it to the function. What's the deal here?

Script / Dynamic Message Box Creation
« on: 2006-11-29, 09:16:59 PM »
We finally got out of the physics testing stage and got into the real making of the game! We're anticipating a lot of dialogue, like, the same NPCs say different things at different points in the game. I figure it'd be much easier to create the special functions dynamically. I'd like to have one special function per NPC to raise an event. I'll test some value "progress" in script and create and immediately trigger a message box function.

I saw in an earlier thread (and in the GoldYoink code) how to create a function for changing maps, but I'll hazard a guess that message boxes are a little different. So, um... how exactly do I do that?

Pages: [1] 2