Skip to content

Commit 90498a2

Browse files
committed
First Commit
0 parents  commit 90498a2

File tree

7 files changed

+165
-0
lines changed

7 files changed

+165
-0
lines changed

Dinraal

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"folders": [
3+
{
4+
"retained": "E64A95092FCA80853577321769BF33F7:Dinraal",
5+
"path": "/Dinraal"
6+
},
7+
{
8+
"retained": "B8B47FE13002C6AF8FBD52C24767660C:dinraal",
9+
"path": "/dinraal"
10+
}
11+
]
12+
}

Smaug.toml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[project]
2+
# The name of your game's executable. This should only contain a-z, A-Z, 0-9, _ or -.
3+
name = "dinraal"
4+
# The game's title. This will show up in the tile bar of your executable.
5+
title = "dinraal"
6+
version = "0.1.0"
7+
authors = ["TODO: My Name <todo@example.com>"]
8+
icon = "metadata/icon.png"
9+
compile_ruby = false
10+
11+
[dragonruby]
12+
version = "2.26"
13+
edition = "standard"
14+
15+
[dependencies]
16+
17+
[itch]
18+
# The Project URL you set when you created the game on Itch.io. https://my-username.itch.io/my-game.
19+
# This will also be the name of your build files, so fill it out even if you aren't uploading to Itch.io.
20+
url = "todo-change-me"
21+
# Your username on Itch.io.
22+
username = "todo-change-me"

app/lib/dinraal.rb

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
module Dinraal
2+
def center(options = {})
3+
x = options[:x]
4+
y = options[:y]
5+
x2 = options[:x2]
6+
y2 = options[:y2]
7+
x3 = options[:x3]
8+
y3 = options[:y3]
9+
10+
{ x: ((x + x2 + x3) / 3).to_i, y: ((y + y2 + y3) / 3).to_i }
11+
end
12+
13+
def outline(options = {})
14+
x = options[:x]
15+
y = options[:y]
16+
x2 = options[:x2]
17+
y2 = options[:y2]
18+
x3 = options[:x3]
19+
y3 = options[:y3]
20+
r = options[:r]
21+
g = options[:g]
22+
b = options[:b]
23+
a = options[:a]
24+
25+
lines = []
26+
lines << { x: x, y: y, x2: x2, y2: y2, r: r, g: g, b: b, a: a }.line!
27+
lines << { x: x3, y: y3, x2: x2, y2: y2, r: r, g: g, b: b, a: a }.line!
28+
lines << { x: x, y: y, x2: x3, y2: y3, r: r, g: g, b: b, a: a }.line!
29+
lines
30+
end
31+
32+
def raster(options = {})
33+
x = options[:x]
34+
y = options[:y]
35+
x2 = options[:x2]
36+
y2 = options[:y2]
37+
x3 = options[:x3]
38+
y3 = options[:y3]
39+
r = options[:r]
40+
g = options[:g]
41+
b = options[:b]
42+
a = options[:a]
43+
44+
args = $gtk.args
45+
triangle = [[x, y], [x2, y2], [x3, y3]]
46+
triangle = triangle.sort_by { |point| point[1] }
47+
triangle = triangle.reverse
48+
49+
line_slope = args.geometry.line_slope [triangle[0][0], triangle[0][1], triangle[2][0], triangle[2][1]]
50+
x_intercept = triangle[0][1] - (line_slope * triangle[0][0])
51+
52+
vertex4 = [(triangle[1][1] - x_intercept) / line_slope, triangle[1][1]]
53+
54+
leg0 = [triangle[0], triangle[1]]
55+
leg0_slope = args.geometry.line_slope(leg0.flatten)
56+
leg0_intercept = triangle[0][1] - (leg0_slope * triangle[0][0])
57+
58+
leg1 = [triangle[0], vertex4]
59+
leg1_slope = args.geometry.line_slope(leg1.flatten)
60+
leg1_intercept = triangle[0][1] - (leg1_slope * triangle[0][0])
61+
62+
leg2 = [triangle[2], triangle[1]]
63+
leg2_slope = args.geometry.line_slope(leg2.flatten)
64+
leg2_intercept = triangle[2][1] - (leg2_slope * triangle[2][0])
65+
66+
leg3 = [triangle[2], vertex4]
67+
leg3_slope = args.geometry.line_slope(leg3.flatten)
68+
leg3_intercept = triangle[2][1] - (leg3_slope * triangle[2][0])
69+
70+
raster_lines = []
71+
72+
y_iter = triangle[0][1]
73+
while y_iter >= vertex4[1]
74+
raster_lines << {
75+
x: (y_iter - leg0_intercept) / leg0_slope,
76+
y: y_iter,
77+
x2: (y_iter - leg1_intercept) / leg1_slope,
78+
y2: y_iter,
79+
r: r, g: g, b: b, a: a
80+
}.line!
81+
y_iter -= 1
82+
end
83+
84+
y_iter = triangle[2][1]
85+
while y_iter <= vertex4[1]
86+
raster_lines << {
87+
x: (y_iter - leg2_intercept) / leg2_slope,
88+
y: y_iter,
89+
x2: (y_iter - leg3_intercept) / leg3_slope,
90+
y2: y_iter,
91+
r: r, g: g, b: b, a: a
92+
}.line!
93+
y_iter += 1
94+
end
95+
raster_lines
96+
end
97+
end
98+
99+
Dinraal.extend Dinraal

app/main.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'app/lib/dinraal.rb'
2+
3+
def tick(args)
4+
tri1 = { x: 100, y: 100, x2: 250, y2: 600, x3: 900, y3: 500, r: 255 }
5+
args.outputs.primitives << Dinraal.raster(tri1)
6+
7+
tri2 = { x: 100, y: 100, x2: 700, y2: 100, x3: 900, y3: 500, g: 255 }
8+
args.outputs.primitives << Dinraal.outline(tri2)
9+
10+
args.outputs.primitives << Dinraal.center(tri1).merge(w: 5, h: 5, g: 255, primitive_marker: :solid)
11+
12+
args.outputs.primitives << Dinraal.center(tri2).merge(w: 5, h: 5, g: 255, primitive_marker: :solid)
13+
end

metadata/game_metadata.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file was automatically @generated by Smaug.
2+
# Do not manually edit this file. Edit Smaug.toml instead.
3+
4+
devid=todo-change-me
5+
devtitle=TODO: My Name &lt;todo@example.com&gt;
6+
gameid=dinraal
7+
gametitle=dinraal
8+
version=0.1.0
9+
icon=metadata/icon.png
10+
compile_ruby=false

metadata/icon.png

153 KB
Loading

metadata/ios_metadata.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# ios_metadata.txt is used by the Pro version of DragonRuby Game Toolkit to create iOS apps.
2+
# Information about the Pro version can be found at: http://dragonruby.org/toolkit/game#purchase
3+
4+
# teamname needs to be set to your assigned team id which can be found at https://developer.apple.com/account/#/membership/L7H57V9CRD
5+
teamid=
6+
# appid needs to be set to your application identifier which can be found at https://developer.apple.com/account/resources/identifiers/list
7+
appid=
8+
# appname is the name you want to show up underneath the app icon on the device
9+
appname=

0 commit comments

Comments
 (0)