Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 01 Oct 2014, 17:02
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
simple game framework for scripting languages
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 3 of 5 Posts_count   Goto page: Previous 1, 2, 3, 4, 5 Next
Author Message
technosaurus


Joined: 18 May 2008
Posts: 4351

PostPosted: Mon 24 Dec 2012, 01:38    Post_subject:  

It's an svg image. Scripts begin with #!/bin/something and need to have the executable bit set.
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
linuph


Joined: 03 Jun 2012
Posts: 128
Location: Philippines

PostPosted: Mon 24 Dec 2012, 02:53    Post_subject:  

Using #!/bin/sh now, but the 'newline' error remains. Same in #!/bin/ash, if that means anything. I understand that '<' has special meaning in Bash, reason for the error. What could be the problem?
Back to top
View user's profile Send_private_message 
Keef


Joined: 20 Dec 2007
Posts: 629
Location: Staffordshire

PostPosted: Mon 24 Dec 2012, 10:01    Post_subject:  

I'm just guessing here, but after looking at other examples on the page, is your code sequence quoted properly?
eg
Code:
 echo ' < blah blah> '
Back to top
View user's profile Send_private_message 
linuph


Joined: 03 Jun 2012
Posts: 128
Location: Philippines

PostPosted: Mon 24 Dec 2012, 20:39    Post_subject:  

Thanks Keef. Being not quoted was the problem. I had a thorough misunderstanding of how the svgame program works. Solved.
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4351

PostPosted: Mon 31 Dec 2012, 15:43    Post_subject:  

to further confuse everyone new to this topic, here is my latest research results for svg and "sprites"... I found it easier to include a second svg rather than the more complicated method of filling a rectangle with a pattern from an image (it may be slower to render but I couldn't figure out a good way to slice the png sprites for fill patterns)

Code:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="512" height="354" viewBox="0 176 256 176">

<image xlink:href="zelda-map.png" height="1408" width="4096" />

<svg x="32" y="240" width="16" height="16" viewBox="0 0 16 16">
<image xlink:href="link.png" width="432" height="303" />
</svg>

</svg>

Note: the <image> width and height are the total width and height of the image whereas the <svg> width and height are the displayed width and height
Note2: the viewbox is xoffset yoffset width height of the image "slice"
Note3: the link.png image has an x and y attribute that are relative to the actual image size from the parent viewbox (0 and 176 in this case) ... thus the image will be scaled to 32x32 since the parent is scaled 2x2 (width='512' height='354' with viewport width of 256 and 176 ... such that the main width and height can be set to 100% for full scale rendering without having to calculate the values for all of the sprites)
zelda.png
 Description   result
 Filesize   44.84 KB
 Viewed   541 Time(s)

zelda.png

zelda-map.png
Description 
png

 Download 
Filename  zelda-map.png 
Filesize  157.25 KB 
Downloaded  295 Time(s) 
link.png
 Description   
 Filesize   6.74 KB
 Viewed   565 Time(s)

link.png


_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Tue 01 Jan 2013, 16:11    Post_subject:  

technosaurus wrote:
to further confuse everyone new to this topic, here is my latest research results for svg and "sprites"... I found it easier to include a second svg rather than the more complicated method of filling a rectangle with a pattern from an image (it may be slower to render but I couldn't figure out a good way to slice the png sprites for fill patterns)

technosaurus,

Thanks for your latest which will take me some time to digest Very Happy

Do you have by any chance, a small game you could show using this technique?

Your experimentation with this stuff is always fascinating.

Happy New Year,
s
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4351

PostPosted: Tue 01 Jan 2013, 21:47    Post_subject:  

seaside wrote:
Do you have by any chance, a small game you could show using this technique?
Not that I would be comfortable publishing due to copyrights (as the last example shows, I have been just using existing tilesets, maps and sprites for experimenting, but more than that would fall outside of "fair use"). I would like to make a block pushing puzzle game along the lines of Adventures of Lolo, an RPG reminiscent of Final Fantasy (the original NES version), an adventure game similar to Zelda or possibly a strategy game like Civilizations, Warcraft or Sim City. These top view 2D (or 2.5D) games were always the most fun (for me at least), perhaps because less resources were spent developing the game engine and graphics and more effort was put into developing the game play?

There are several free tile and sprite sets available, but at the time I looked at them, I didn't have a good way of slicing the sprites/tiles. I would actually recommend using the tilesets to pre-generate the map from some type of array though, so that static tiles don't need to be separately parsed and rendered during game play... the array could still be used during gameplay for collision detection etc... Imagine how slow the Zelda example could be if all of the tiles for the large map had to be rendered as separate svg images. Only rendering the changeable objects in the currently visible screen rather than the whole map also helps for the Zelda case, but for some game types the off screen actions are important (real time strategy games for example)

Edit: I've also considered a method of implementing some type of gravity physics for side scrollers. The simplest I can come up with is to set a time it takes to fall 1 grid section and divide it by 4 for each additional section it falls until it gets to some minimum (terminal velocity)... That would open up a few extra genres.

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4351

PostPosted: Wed 09 Jan 2013, 17:13    Post_subject:  

If anyone would like to do a side scroller, this is a good reference:
http://www.khanacademy.org/cs/jumpgirl/939844470

It is written in javascript, but the concepts are pretty similar.

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
linuph


Joined: 03 Jun 2012
Posts: 128
Location: Philippines

PostPosted: Sat 12 Jan 2013, 11:02    Post_subject:  

@technosaurus

A bit off topic...

I have mutilated your original C script just to enable a windowless svg image. I don't need a watch (inotify) or anything else, except that it is there in the background until my program decides to kill it. I run it from BASH with 'runbgrpic3' (after compilation) and kill it by killing its pidof.

The script is attached. It works but there's needless code in it, I suppose. Since I'm a total noob in C/GTK, I don't know how to optimize it. Not that it is a problem, but I don't like stupid code.

Can you advise?

Code:
#include <gtk/gtk.h>
#define IMAGE "GPSr2-bgr3.svg"

int main(int argc, char *argv[]){
   int watch,fd; GtkWidget *window, *image;
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
/* leave out window decoration */
gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
image = gtk_image_new_from_file(IMAGE);
gtk_container_add(GTK_CONTAINER(window), image);
gtk_widget_show_all(window);
gtk_main ();}
Back to top
View user's profile Send_private_message 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Sun 13 Jan 2013, 13:56    Post_subject:  

linuph wrote:
@technosaurus

The script is attached. It works but there's needless code in it, I suppose. Since I'm a total noob in C/GTK, I don't know how to optimize it. Not that it is a problem, but I don't like stupid code.

linuph,

As far as I can see the only item you could eliminate is the line
Code:
int watch,fd;
since you don't need it.

Everything else seems to me to be the minimum necessary to show your image.

Cheers,
s
Back to top
View user's profile Send_private_message 
starhawk

Joined: 22 Nov 2010
Posts: 2879
Location: Everybody knows this is nowhere...

PostPosted: Sun 13 Jan 2013, 14:08    Post_subject:  

Taking a bit of a leap of faith here, hope this is the right thread for this.

technosaurus, I program in an archaic language (BASIC is dead, long live BASIC) taught to me originally by my first computer -- a 386 running Win3.1 (this was in the mid- to late-'90s). LOL.

I wrote a pretty nifty text adventure, but its primary characteristic is that I wrote it and made it work without knowing how to make a parser. The way it works is that the entire input string from the player, is compared against a bunch of possible input strings (which can do stuff) using a bunch of IF-THEN statements.

I think it's fair to say that I'm rather aware of just how bad that actually is, coding-wise.

Would you be able to either provide me or locate for me, simple instructions for a text parser in this language? I've looked high and low and can't find anything on my own. I guess my Google-Fu is weak (old man).

I'm most familiar with QBASIC/QuickBASIC (QuickBASIC compiles, is about the only difference) but I can learn QB64 and *maybe* BaCon if need be... I just want to be able to implement a simple parser. Then I can re-code the game and it will work better. (...and I might even be able to make it bigger -- current version is a mere eight rooms, and that was quite a stretch with all that clumsy code!)

_________________
Loving X-Slacko 2.1!
Custom Build: HP MOCA-AR + Core2Duo T7200 + 4gb RAM + 256gb SSD
...just needs a pretty case Wink
Back to top
View user's profile Send_private_message 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Sun 13 Jan 2013, 16:40    Post_subject:  

starhawk wrote:


Would you be able to either provide me or locate for me, simple instructions for a text parser in this language? I've looked high and low and can't find anything on my own. I guess my Google-Fu is weak (old man).



starhawk,

How about this-
http://ascii-world.wikidot.com/how-to-program-a-simple-text-parser

Cheers,
s
Back to top
View user's profile Send_private_message 
starhawk

Joined: 22 Nov 2010
Posts: 2879
Location: Everybody knows this is nowhere...

PostPosted: Sun 13 Jan 2013, 19:49    Post_subject:  

I can barely read that, TBH... the QuickBASIC I learned is Procedural, not Object Oriented. I'm still using line numbers and GOTOs!

I'll study it, but I'm not sure it'll work for me.

_________________
Loving X-Slacko 2.1!
Custom Build: HP MOCA-AR + Core2Duo T7200 + 4gb RAM + 256gb SSD
...just needs a pretty case Wink
Back to top
View user's profile Send_private_message 
linuph


Joined: 03 Jun 2012
Posts: 128
Location: Philippines

PostPosted: Mon 14 Jan 2013, 06:56    Post_subject:  

Seaside, thanks!
Back to top
View user's profile Send_private_message 
starhawk

Joined: 22 Nov 2010
Posts: 2879
Location: Everybody knows this is nowhere...

PostPosted: Mon 14 Jan 2013, 12:50    Post_subject:  

linuph wrote:
Seaside, thanks!


This is something I should have said as well -- the effort is appreciated for sure, even if the code produced is incomprehensible to me -- after all, it's not your fault, Seaside, that I can't read newfangled code!

So THANK YOU for showing me that parser, even though it's something I couldn't use.

Also, THANK YOU jamesbond, for sending me another one which may be of use (I haven't looked at it yet, TBH -- it's a ZIP file and I only just downloaded it.)

_________________
Loving X-Slacko 2.1!
Custom Build: HP MOCA-AR + Core2Duo T7200 + 4gb RAM + 256gb SSD
...just needs a pretty case Wink
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 3 of 5 Posts_count   Goto page: Previous 1, 2, 3, 4, 5 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0922s ][ Queries: 12 (0.0048s) ][ GZIP on ]