Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 03d765d0cd
commit 758ca64cc6
  1. BIN
      C++ProjectTemplate
  2. 300
      input
  3. 114
      main.cpp

Binary file not shown.

300
input

@ -0,0 +1,300 @@
DMwrszrfMzSSCpLpfCCn
RMvhZhQqlvhMvRtbvbcPclPlncddppLTdppd
tVMQhFtjjWmsFJsmsW
trRtvNhfJhSzzSTFVhQQZQhHGphP
CnLMBWLwDMgMcwwdngdHGPVTQGpTHZdGPGpd
LLDqcDgwqCMnLWqtvzrzbbtJqPjJ
wQQwHNQLmbWQbQRHwHNFBbwqPfjqlzRMGRqzpSfvPlzplM
nCtGCZZtsGsrtDMZpfMpSlMlvlZq
cJctJCgVJsCJnDTsCthGhGLwBWBbbQmLbgQLQQdWbbbQ
ZWnNlTNTnhhQQlDNdmmpwrrrqBwjwjZd
GzvlVRSfvMVMvGlSpdCCdjmfpmBCdsqB
bzlFlLzJWLHHttLL
SmzFhVDzrmSrszVDVhSVbhZcCZdfZNcnMfMbZnNN
PTTRGqwqTqWRwLgTLTZGnCbZbNddZCCtMcNs
sgPqPqgJgWWqjjwgwLLVFBFSVmvmBBrmJJDSvp
CBccfSBhcSBddfgtlJmmmwmPRwmh
FpTzzGWHWprgDtJlDZDPFR
HbbTzWnTrnWtCbQBbQqQbSjf
fPHspCjgwZggSvZQ
RrNhzFZFcNzFLNLNwQlSlLnv
TRFrcDVrrRmrhFRZzVrczqhRpjqjsssCpfHjsCdpsPfpjCMC
ZBnBTMVTSbGbTVTGbCPgqsgPtHtgCcPtBB
ldDrmnnNrzhdhfgcsHqcsfCcsCHg
zFdrzNdzQNDDhFdWldDrJTbZTbLZJVVVpMVWVnLS
pLnpQNhBbnWvbsWm
FrFwjlTPTdTqqrDZWbvmZbpSgmJWvbgS
RqDqRrdGFpGRFrFFdTNzCcHcHLHBzQCcNNGN
bvRCtbtCPfSGtCcvCbPNlglqgqlGZMzTgnlZnq
hrmWWFspsHWrzNwT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NJHpmHTDnTNJqnFCgBLFLFzFtsQRCd
NpMJHpnMrDpJGTHqTTmJHTPjfcvbWfrffVzvZfVWSbjz
wFwpqWwwpqwtqqrbCFtptDmCcfNhNRzRBZRRJRChVNBZBJ
svlvjHsQlvdlvMLdlvPSSLtzzczcNhJthfNtRcNMJNMc
HvvPLSHjgltjsvqwbbnmWmDpgwTT
zhCmPVwwChdCBtsWnNWswBWr
GJJSfSgFpjJjGgpfpgrcNNstvnBHNnHLtFHr
jgDTfjpMgZMGMGJTMMJRhzZPCzbhVlPqdNCbhd
bDbQQmVDRpDNbRQlfQQZnfwTlllfsT
FChzzBWhVzrgMwffJwlnngnTlJ
MCvqvhFzcHCChjtpNNVLppGmbq
bZZzJnccqdzcLhrcQDLrDs
FfCfWVfjWTFClClfwjWCfGGwhZSDhSLsSSRpZprLph
mFmTMmFjMMWFfZtttflWjmWTngNHJHggJJHtzgnJvBtBgHdv

@ -4,86 +4,46 @@
using namespace olc;
class Example : public olc::PixelGameEngine
int main()
{
public:
Example()
{
sAppName = "Example";
}
public:
bool RayVsRect(const vf2d ray_origin, const vf2d ray_dir, const olc::utils::geom2d::rect<float> target, vf2d&contact_point, vf2d&contact_normal, float&t_hit_near){
contact_normal = { 0, 0 };
contact_point = { 0, 0 };
vf2d t_near = {(target.pos.x - ray_origin.x) / ray_dir.x, (target.pos.y - ray_origin.y) / ray_dir.y};
vf2d t_far = {(target.pos.x + target.size.x - ray_origin.x) / ray_dir.x, (target.pos.y + target.size.y - ray_origin.y) / ray_dir.y};
if (t_near.x > t_far.x) {float b; b = t_near.x; t_near.x = t_far.x; t_far.x = b;};
if (t_near.y > t_far.y) {float b; b = t_near.y; t_near.y = t_far.y; t_far.y = b;};
if (t_near.x > t_far.y || t_near.y > t_far.x) return false;
t_hit_near = fmax(t_near.x, t_near.y);
float t_hit_far = fmin(t_far.x, t_far.y);
if (t_hit_far < 0) return false;
contact_point.x = ray_origin.x + t_hit_near * ray_dir.x;
contact_point.y = ray_origin.y + t_hit_near * ray_dir.y;
if (t_near.x > t_near.y)
if ( 1.0f / ray_dir.x < 0)
contact_normal = { 1, 0 };
else
contact_normal = { -1, 0};
else
if ( t_near.x < t_near.y)
if ( 1.0f / ray_dir.y < 0)
contact_normal = { 0, 1 };
else
contact_normal = { 0, -1 };
return true;
}
vf2d originPoint={16,16};
bool OnUserCreate() override
{
// Called once at the start, so create things here
return true;
}
bool OnUserUpdate(float fElapsedTime) override
{
vf2d velocity={(GetKey(D).bHeld-GetKey(A).bHeld)*20*fElapsedTime,(GetKey(S).bHeld-GetKey(W).bHeld)*20*fElapsedTime};
vf2d contact_point;
vf2d contact_normal;
float t_hit_near;
Clear(Pixel(64,64,255));
if (!olc::utils::geom2d::overlaps(olc::utils::geom2d::circle<float>{originPoint+velocity,5},olc::utils::geom2d::rect<float>{{32,32},{64,32}})) {
originPoint+=velocity;
DrawCircle(originPoint,5);
} else {
DrawCircle(originPoint,5,RED);
std::ifstream file("input");
int sum=0;
while (file.good()) {
std::string line;
std::string line2;
std::string line3;
std::getline(file,line);
std::getline(file,line2);
std::getline(file,line3);
if (line.length()>0) {
std::cout<<"=========="<<std::endl;
std::cout<<line<<std::endl;
std::cout<<line2<<std::endl;
std::cout<<line3<<std::endl;
for (int i=0;i<line.length();i++) {
for (int j=0;j<line2.length();j++) {
for (int k=0;k<line3.length();k++) {
if (line[i]==line2[j]&&line2[j]==line3[k]&&line[i]==line3[k]) {
if (line[i]>='A'&&line[i]<='Z') {
int prio=27+line[i]-'A';
sum+=prio;
std::cout<<"Prio "<<prio<<" for "<<line[i]<<std::endl;
} else {
int prio=1+line[i]-'a';
sum+=prio;
std::cout<<"Prio "<<prio<<" for "<<line[i]<<std::endl;
}
goto outer;
}
}
}
}
outer:;
}
DrawLine(originPoint,GetMousePos());
DrawRect({32,32},{64,32},RayVsRect(originPoint, GetMousePos()-originPoint, olc::utils::geom2d::rect<float>{{32,32},{64,32}},contact_point,contact_normal,t_hit_near)&&t_hit_near<1?YELLOW:WHITE);
return true;
}
};
}
int main()
{
Example demo;
if (demo.Construct(128, 120, 8, 8))
demo.Start();
std::cout<<"Sum: "<<sum<<std::endl;
return 0;
}

Loading…
Cancel
Save