simple game framework for scripting languages
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
I'm just guessing here, but after looking at other examples on the page, is your code sequence quoted properly?
eg
eg
Code: Select all
echo ' < blah blah> '
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
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)
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)
Code: Select all
<?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>
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)
- Attachments
-
- zelda.png
- result
- (44.84 KiB) Downloaded 622 times
-
- zelda-map.png
- (157.25 KiB) Downloaded 622 times
-
- link.png
- (6.74 KiB) Downloaded 737 times
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
technosaurus,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)
Thanks for your latest which will take me some time to digest
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
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
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?seaside wrote:Do you have by any chance, a small game you could show using this technique?
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.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
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.
http://www.khanacademy.org/cs/jumpgirl/939844470
It is written in javascript, but the concepts are pretty similar.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
@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?
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: Select all
#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 ();}
linuph,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.
As far as I can see the only item you could eliminate is the line
Code: Select all
int watch,fd;
Everything else seems to me to be the minimum necessary to show your image.
Cheers,
s
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!)
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!)
starhawk,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).
How about this-
http://ascii-world.wikidot.com/how-to-p ... ext-parser
Cheers,
s
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!linuph wrote:Seaside, thanks!
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.)
Icon programming.
I've been digging lately to find a graphics programming language without bloating dependencies. I think I found one: Icon. You may never have heard of it.
See here: http://www.cs.arizona.edu/icon/index.htm
It's ancient in software/computer terms (1998). The earliest mention of it that I found dates back to 1979.
I downloaded the packages from the above website, compiled it with X11 headers and dropped the resulting directory with files into ~/bin and made a symlink.
Guess what: it works flawlessly. And it is rather easy to understand, even for me
Below some examples I made with the help of the excellent documentation in an hour or so. But there's lot more to Icon than this, like high level string handling and Turtle Graphics, so I'm venturing on with it.
I would have liked to attach the Icon compilation as well, but it's 1.7Mb zipped (9Mb unzipped).
BTW there's Unicon (http://unicon.sourceforge.net/faq.htm) which is a 'modernized dialect that descends from Icon", but I have not yet looked into it.
I thought you might be interested....
I've been digging lately to find a graphics programming language without bloating dependencies. I think I found one: Icon. You may never have heard of it.
See here: http://www.cs.arizona.edu/icon/index.htm
It's ancient in software/computer terms (1998). The earliest mention of it that I found dates back to 1979.
I downloaded the packages from the above website, compiled it with X11 headers and dropped the resulting directory with files into ~/bin and made a symlink.
Guess what: it works flawlessly. And it is rather easy to understand, even for me
Below some examples I made with the help of the excellent documentation in an hour or so. But there's lot more to Icon than this, like high level string handling and Turtle Graphics, so I'm venturing on with it.
I would have liked to attach the Icon compilation as well, but it's 1.7Mb zipped (9Mb unzipped).
BTW there's Unicon (http://unicon.sourceforge.net/faq.htm) which is a 'modernized dialect that descends from Icon", but I have not yet looked into it.
I thought you might be interested....
Code: Select all
#!/bin/icon
# fonts
link graphics
procedure main()
WOpen("size=600,200") | stop("Can't open window")
WAttrib("pos=50,150")
WAttrib("label=Icon Programming - Fonts Demonstration")
GotoXY(10,50)
ransom("The quick brown fox jumps over the lazy dog.")
WDone()
end
procedure ransom(s)
local c
static famlist, attlist, sizelist
initial
{
famlist:=["URW Chancery L","DejaVu Sans"]
attlist:=["","","bold","italic"]
sizelist:=[18,22,24,32,34]
}
every c:=!s do
{
Font(?famlist || "," || ?sizelist || "," || ?attlist)
WWrites(c)
}
return
end
Code: Select all
#!/bin/icon
#clipping
link graphics
procedure main()
local x,y
WOpen("size=600,400", "bg=yellow")
WAttrib("pos=300,100")
WAttrib("label=Icon Programming - Clipping")
Fg("red")
FillRectangle(50,50,400,300)
Fg("green")
FillRectangle(70,70,360,260)
Clip(71,71,359,259)
every 1 to 50 do
{
x:=?400+50
y:=?300+50
WAttrib("fg=black","linewidth=5")
DrawCircle(x,y,30)
WAttrib("fg=white","linewidth=3")
DrawCircle(x,y,30)
}
WDone()
end
Code: Select all
#!/bin/icon
# Sierpinsky
$define Width 400
$define Height 400
$define X1 0
$define Y1 Height
$define X2 (Width/2)
$define Y2 0
$define X3 Width
$define Y3 Height
link graphics
procedure main()
local x,y
WOpen("size=400,400", "bg=light green")
WAttrib("label=Icon Programming - Sierpinski Diagram")
Fg("red")
WWrite("Press 'q' to quit")
Fg("black")
x:=Width/2
y:=Height/2
until WQuit() do
{
case ?3 of
{
1: {
x:=(x+X1)/2
y:=(y+Y1)/2
}
2: {
x:=(x+X2)/2
y:=(y+Y2)/2
}
3: {
x:=(x+X3)/2
y:=(y+Y3)/2
}
}
DrawPoint(x,y)
}
end
- Attachments
-
- Sierpinsky.png
- (17.13 KiB) Downloaded 344 times
-
- clipping.png
- (19.35 KiB) Downloaded 357 times
-
- fonts.png
- (8.25 KiB) Downloaded 356 times
width and height variable in svg
Hi Everyone, i very2 new in programming with svg. I want to make a background that can be full screen. but i can't change the variable WIDTH and HEIGHT in my script. this is my script:
The variable USER can reference to $HOSTNAME, but why WIDTH and HEIGHT can't?
How to solve my problem?
Thank you.
Code: Select all
#!/bin/sh
if [ -f startku.jpg ]; then
rm startku.jpg
fi
USER=$HOSTNAME
RES=$(xrandr | grep "current" | cut -d 'c' -f1,3 | tr -cd 'x [:digit:]' | cut -d 'x' -f1,2)
WIDTH=$(echo $RES | cut -d 'x' -f1,1)
HEIGHT=$(echo $RES | cut -d 'x' -f2,3)
echo '
<svg version="1.1">
<rect width="1366" height="768"
style="fill:rgb(0,0,255)"/>
<text >
<tspan x="550" y="500" font-family="Open Sans" font-weight="bolder" font-size="100"
fill="white" letter-spacing="-5">
limuks
</tspan>
<tspan x="550" y="530" font-family="Open Sans" font-weight="lighter" font-size="30"
fill="white">
'"$USER"''"'"'s puppy linux
</tspan>
</text>
<path stroke-dasharray="20,10,5,5,5,10" d="M5 60 215 0" />
<circle cx="370" cy="100" r="12" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="350" cy="140" r="10" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="400" cy="110" r="5" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="410" cy="130" r="5" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="430" cy="120" r="2" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="300" cy="110" r="40" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="300" cy="110" r="33" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="300" cy="110" r="21" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="700" cy="100" r="80" fill="#6BADF6" style="fill-opacity:0.2"/>
<circle cx="700" cy="100" r="60" fill="#6BADF6" style="fill-opacity:0.2"/>
<circle cx="700" cy="100" r="40" fill="#6BADF6" style="fill-opacity:0.2"/>
<circle cx="700" cy="100" r="20" fill="#6BADF6" style="fill-opacity:0.2"/>
<circle cx="1000" cy="150" r="100" fill="#6BADF6" style="fill-opacity:0.2"/>
<circle cx="1000" cy="150" r="80" fill="#6BADF6" style="fill-opacity:0.2"/>
<circle cx="1000" cy="150" r="60" fill="#6BADF6" style="fill-opacity:0.2"/>
<circle cx="1000" cy="150" r="45" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1000" cy="150" r="30" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1000" cy="150" r="15" fill="#6BADF6" style="fill-opacity:0.5"/>
<circle cx="300" cy="700" r="20" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="300" cy="700" r="10" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="300" cy="700" r="5" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="400" cy="710" r="20" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="400" cy="710" r="10" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="400" cy="710" r="5" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="500" cy="730" r="30" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="500" cy="730" r="23" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="500" cy="730" r="16" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="640" cy="700" r="30" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="640" cy="700" r="20" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="640" cy="700" r="7" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="700" cy="680" r="30" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="700" cy="680" r="20" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="700" cy="680" r="5" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="900" cy="720" r="20" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="900" cy="720" r="10" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="900" cy="720" r="5" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="935" cy="700" r="20" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="935" cy="700" r="10" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="935" cy="700" r="5" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1000" cy="680" r="30" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1000" cy="680" r="20" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1000" cy="680" r="15" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1000" cy="680" r="10" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1050" cy="710" r="20" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1050" cy="710" r="10" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1050" cy="710" r="5" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1100" cy="735" r="20" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1100" cy="735" r="10" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1100" cy="735" r="5" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1200" cy="730" r="20" fill="#6BADF6" style="fill-opacity:0.5"/>
<circle cx="1200" cy="730" r="10" fill="#6BADF6" style="fill-opacity:0.3"/>
<circle cx="1200" cy="730" r="5" fill="#6BADF6" style="fill-opacity:0.3"/>
</svg>' > startku.jpg
if [ -f /usr/share/backgrounds/startku.jpg ]; then
rm /usr/share/backgrounds/startku.jpg
fi
cp startku.jpg /usr/share/backgrounds/startku.jpg&
wallpaper /usr/share/backgrounds/startku.jpg&
defaultimageviewer startku.jpg
How to solve my problem?
Thank you.
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
you need to set width and height in the svg tag as in this post:
http://murga-linux.com/puppy/viewtopic. ... 581#674581
edit: and its not a jpg
edit2:and you arent using the HEIGHT and WIDTH variables anywhere
http://murga-linux.com/puppy/viewtopic. ... 581#674581
edit: and its not a jpg
edit2:and you arent using the HEIGHT and WIDTH variables anywhere
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
thank you technosaurus,
i mean the width and height is at rectangle
if i change
with
i don't see any rectangle. just black screen with text and circle.
i looked at this thread:
http://murga-linux.com/puppy/viewtopic. ... 253#647253
and you can use $BACKGROUND variable in the svg's script. but why in my script don't work?
thank you
i mean the width and height is at rectangle
if i change
Code: Select all
<rect width="1366" height="768"
style="fill:rgb(0,0,255)"/>
Code: Select all
<rect width="'$WIDTH'" height="'$HEIGHT'"
style="fill:rgb(0,0,255)"/>
i looked at this thread:
http://murga-linux.com/puppy/viewtopic. ... 253#647253
and you can use $BACKGROUND variable in the svg's script. but why in my script don't work?
thank you
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
probably because it is the size of your screen. you can make it any size and it will stretch to fill the window if you have the right aspect ratio. removing the title bar is different though, depends on wm settings or modifying the source code
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].